diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5eb51914..82b2b973 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,10 +9,29 @@ updates: schedule: interval: "monthly" # Labels on pull requests for version updates only - labels: - - "ci" + labels: ["ci"] pull-request-branch-name: # Separate sections of the branch name with a hyphen for example, `dependabot-npm_and_yarn-next_js-acorn-6.4.1` separator: "-" # Allow up to 5 open pull requests for GitHub Actions open-pull-requests-limit: 5 + reviewers: + - "borda" + + # Enable version updates for python + - package-ecosystem: "pip" + # Look for a `requirements` in the `root` directory + directory: "/requirements" + # Check for updates once a week + schedule: + interval: "weekly" + # Labels on pull requests for version updates only + labels: ["enhancement"] + pull-request-branch-name: + # Separate sections of the branch name with a hyphen + # for example, `dependabot-npm_and_yarn-next_js-acorn-6.4.1` + separator: "-" + # Allow up to 5 open pull requests for pip dependencies + open-pull-requests-limit: 5 + reviewers: + - "willingc" diff --git a/.gitignore b/.gitignore index 5eeb0b76..3ecd135c 100644 --- a/.gitignore +++ b/.gitignore @@ -123,3 +123,7 @@ pip-wheel-metadata # VIM swap files *.swp + + +# lint +.ruff_cache/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 29f7cb40..adb877b6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: rev: v3.15.0 hooks: - id: pyupgrade - args: [--py37-plus] + args: ["--py38-plus"] name: Upgrade code #- repo: https://github.com/myint/docformatter @@ -34,10 +34,12 @@ repos: # - id: docformatter # args: [--in-place, --wrap-summaries=120, --wrap-descriptions=120] - #- repo: https://github.com/PyCQA/isort - # rev: 5.10.1 - # hooks: - # - id: isort + - repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell + additional_dependencies: [tomli] + #args: ["--write-changes"] # uncomment if you want to get automatic fixing - repo: https://github.com/psf/black rev: 23.11.0 @@ -58,11 +60,8 @@ repos: hooks: - id: yesqa - - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.4 hooks: - - id: flake8 - arge: - - "--count" - - "--show-source" - - "--statistics" + - id: ruff + args: ["--fix"] diff --git a/DEVELOPMENT_GUIDE.md b/DEVELOPMENT_GUIDE.md index 92ca32ad..368cad8a 100644 --- a/DEVELOPMENT_GUIDE.md +++ b/DEVELOPMENT_GUIDE.md @@ -51,3 +51,28 @@ In `cli.py` you'll want to add an `@click.option` above the `papermill` method a Now in `execute.py`'s `execute_notebook` we want to add the appropriate argument and default it to something sane. Add the argument to the docstring as well. Then pass or use that argument where it's needed to achieve the desired effect. Usually these options get passed to `_execute_parameterized_notebook`. To update the tests you'll need both `test_cli.py` and `test_execute.py` to include the new option. Though the CLI tests need only check that the appropriate values get passed to `execute_notebook`. + +# Releasing + +## Prerequisites + +- First check that the CHANGELOG is up to date for the next release version +- Ensure dev requirements are installed `pip install -r requirements/dev.txt` + +## Push to GitHub + +Change from patch to minor or major for appropriate version updates. + +```bash +bumpversion patch +git push upstream && git push upstream --tags +``` + +## Push to PyPI + +```bash +rm -rf dist/* +rm -rf build/* +python setup.py sdist bdist_wheel +twine upload dist/* +``` diff --git a/RELEASING.md b/RELEASING.md deleted file mode 100644 index 12ee7d0a..00000000 --- a/RELEASING.md +++ /dev/null @@ -1,24 +0,0 @@ -# Releasing - -## Prerequisites - -- First check that the CHANGELOG is up to date for the next release version -- Ensure dev requirements are installed `pip install -r requirements/dev.txt` - -## Push to GitHub - -Change from patch to minor or major for appropriate version updates. - -```bash -bumpversion patch -git push upstream && git push upstream --tags -``` - -## Push to PyPI - -```bash -rm -rf dist/* -rm -rf build/* -python setup.py sdist bdist_wheel -twine upload dist/* -``` diff --git a/docs/changelog.md b/docs/changelog.md index 9ca56f16..4d500ada 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -12,19 +12,19 @@ - Added “github” extra deps. to the “all” extra [PR #715](https://github.com/nteract/papermill/pull/715) - Github actions updated to latest version [PR #732](https://github.com/nteract/papermill/pull/732) - Added a warning if non set parameter is passed through CLI [PR #701](https://github.com/nteract/papermill/pull/701) -- Skip black formatting when encounting attribute errors [PR #699](https://github.com/nteract/papermill/pull/699) -- Removed fored deepcopy of notebook objects [PR #694](https://github.com/nteract/papermill/pull/694) +- Skip black formatting when encountering attribute errors [PR #699](https://github.com/nteract/papermill/pull/699) +- Removed forced deepcopy of notebook objects [PR #694](https://github.com/nteract/papermill/pull/694) - Always update notebook version on execute [PR #691](https://github.com/nteract/papermill/pull/691) - Set minimum version for tenacity [PR #682](https://github.com/nteract/papermill/pull/682) - Removed use of ansiwrap [PR #681](https://github.com/nteract/papermill/pull/681) -- Added precommit hook [PR #678](https://github.com/nteract/papermill/pull/678) +- Added pre-commit hook [PR #678](https://github.com/nteract/papermill/pull/678) - Added dependabot for GHA [PR #677](https://github.com/nteract/papermill/pull/677) ## 2.4.0 - Add tracking cell executions with cell descriptions [PR #650](https://github.com/nteract/papermill/pull/650) - Fixed Azure Blob URI matching for prefixes [PR #654](https://github.com/nteract/papermill/pull/654) -- Updates HDFS handler to use PyArrow.fs.HadoopFileSystm [PR #658](https://github.com/nteract/papermill/pull/658) +- Updates HDFS handler to use `PyArrow.fs.HadoopFileSystm` [PR #658](https://github.com/nteract/papermill/pull/658) - Drop support for Python 3.6 [PR #666](https://github.com/nteract/papermill/pull/666) - CI Build fixes [PR #664](https://github.com/nteract/papermill/pull/664) - Updated mock references in tests [PR #668](https://github.com/nteract/papermill/pull/668) @@ -224,7 +224,7 @@ pip install papermill[all] - Optional IO extensions are now separated into different dependencies. - Added gs:// optional dependency for google cloud storage support. -- null json fields in parmaeters now translate correctly to equivilent fields in each supported language +- null json fields in parameters now translate correctly to equivalent fields in each supported language ### Fixes @@ -240,7 +240,7 @@ pip install papermill[all] ### Features - Log level can now be set with `--log-level` -- The working directory of papermill can be set with the `--cwd` option. This will set the executing context of the kernel but not impact input/output paths. `papermill --cwd foo bar/input_nb.ipynb bar/output_nb.ipynb` would make the notebook able to reference files in the `foo` directoy without `../foo` but still save the output notebook in the `bar` directory. +- The working directory of papermill can be set with the `--cwd` option. This will set the executing context of the kernel but not impact input/output paths. `papermill --cwd foo bar/input_nb.ipynb bar/output_nb.ipynb` would make the notebook able to reference files in the `foo` directory without `../foo` but still save the output notebook in the `bar` directory. - Tox has been added for testing papermill. This makes it easier to catch linting and manifest issues without waiting for a failed Travis build. ### Fixes @@ -274,7 +274,7 @@ pip install papermill[all] - Added engines abstraction and command line argument - Moved some nbconvert wrappers out of papermill - Added Azure blob storage support -- Fixed botocore upgrade comptability issue (all version of boto now supported again) +- Fixed botocore upgrade compatibility issue (all version of boto now supported again) - Removed whitelisted environment variable assignment ## 0.15.1 @@ -286,7 +286,7 @@ pip install papermill[all] - Warnings added when an unexpected file extension is used - Papermill version is visible to the CLI - More messages us logging module now (and can be filtered accordingly) -- Binder link from README was greatly improved to demostrate papermill features +- Binder link from README was greatly improved to demonstrate papermill features ## 0.15.0 @@ -333,7 +333,7 @@ pip install papermill[all] ## 0.12.6 - Changed CLI outputs from papermill messaging to stderr -- Changed IOResolvers to perseve ordering of definition in resolving paths +- Changed IOResolvers to persevere ordering of definition in resolving paths ## 0.12.5 diff --git a/papermill/__init__.py b/papermill/__init__.py index af32a9d3..7e691ccf 100644 --- a/papermill/__init__.py +++ b/papermill/__init__.py @@ -1,5 +1,4 @@ -from .version import version as __version__ - -from .exceptions import PapermillException, PapermillExecutionError -from .execute import execute_notebook -from .inspection import inspect_notebook +from .exceptions import PapermillException, PapermillExecutionError # noqa: F401 +from .execute import execute_notebook # noqa: F401 +from .inspection import inspect_notebook # noqa: F401 +from .version import version as __version__ # noqa: F401 diff --git a/papermill/abs.py b/papermill/abs.py index d40db9d2..665d7f69 100644 --- a/papermill/abs.py +++ b/papermill/abs.py @@ -1,9 +1,9 @@ """Utilities for working with Azure blob storage""" -import re import io +import re -from azure.storage.blob import BlobServiceClient from azure.identity import EnvironmentCredential +from azure.storage.blob import BlobServiceClient class AzureBlobStore: @@ -29,7 +29,7 @@ def _blob_service_client(self, account_name, sas_token=None): @classmethod def _split_url(self, url): """ - see: https://docs.microsoft.com/en-us/azure/storage/common/storage-dotnet-shared-access-signature-part-1 # noqa: E501 + see: https://docs.microsoft.com/en-us/azure/storage/common/storage-dotnet-shared-access-signature-part-1 abs://myaccount.blob.core.windows.net/sascontainer/sasblob.txt?sastoken """ match = re.match(r"abs://(.*)\.blob\.core\.windows\.net\/(.*?)\/([^\?]*)\??(.*)$", url) diff --git a/papermill/cli.py b/papermill/cli.py index 5df52760..8593f543 100755 --- a/papermill/cli.py +++ b/papermill/cli.py @@ -1,23 +1,21 @@ """Main `papermill` interface.""" +import base64 +import logging import os +import platform import sys -from stat import S_ISFIFO -import nbclient import traceback - -import base64 -import logging +from stat import S_ISFIFO import click - +import nbclient import yaml -import platform from .execute import execute_notebook -from .iorw import read_yaml_file, NoDatesSafeLoader from .inspection import display_notebook_help -from . import __version__ as papermill_version +from .iorw import NoDatesSafeLoader, read_yaml_file +from .version import version as papermill_version click.disable_unicode_literals_warning = True diff --git a/papermill/clientwrap.py b/papermill/clientwrap.py index cde6f906..7574919e 100644 --- a/papermill/clientwrap.py +++ b/papermill/clientwrap.py @@ -1,5 +1,5 @@ -import sys import asyncio +import sys from nbclient import NotebookClient from nbclient.exceptions import CellExecutionError diff --git a/papermill/engines.py b/papermill/engines.py index 97bc5732..ba075615 100644 --- a/papermill/engines.py +++ b/papermill/engines.py @@ -1,16 +1,16 @@ """Engines to perform different roles""" -import sys import datetime -import dateutil - +import sys from functools import wraps + +import dateutil import entrypoints -from .log import logger -from .exceptions import PapermillException from .clientwrap import PapermillNotebookClient +from .exceptions import PapermillException from .iorw import write_ipynb -from .utils import merge_kwargs, remove_args, nb_kernel_name, nb_language +from .log import logger +from .utils import merge_kwargs, nb_kernel_name, nb_language, remove_args class PapermillEngines: @@ -106,7 +106,7 @@ def __init__(self, nb, output_path=None, log_output=False, progress_bar=True, au self.last_save_time = self.now() # Not exactly true, but simplifies testing logic self.pbar = None if progress_bar: - # lazy import due to implict slow ipython import + # lazy import due to implicit slow ipython import from tqdm.auto import tqdm self.pbar = tqdm(total=len(self.nb.cells), unit="cell", desc="Executing") diff --git a/papermill/exceptions.py b/papermill/exceptions.py index 183c9256..26b68cf8 100644 --- a/papermill/exceptions.py +++ b/papermill/exceptions.py @@ -30,7 +30,7 @@ def __init__(self, cell_index, exec_count, source, ename, evalue, traceback): def __str__(self): # Standard Behavior of an exception is to produce a string representation of its arguments - # when called with str(). In order to maintain compatability with previous versions which + # when called with str(). In order to maintain compatibility with previous versions which # passed only the message to the superclass constructor, __str__ method is implemented to # provide the same result as was produced in the past. message = "\n" + 75 * "-" + "\n" diff --git a/papermill/execute.py b/papermill/execute.py index f0a36165..27e5e493 100644 --- a/papermill/execute.py +++ b/papermill/execute.py @@ -1,13 +1,14 @@ -import nbformat from pathlib import Path -from .log import logger -from .exceptions import PapermillExecutionError -from .iorw import get_pretty_path, local_file_io_cwd, load_notebook_node, write_ipynb +import nbformat + from .engines import papermill_engines -from .utils import chdir -from .parameterize import add_builtin_parameters, parameterize_notebook, parameterize_path +from .exceptions import PapermillExecutionError from .inspection import _infer_parameters +from .iorw import get_pretty_path, load_notebook_node, local_file_io_cwd, write_ipynb +from .log import logger +from .parameterize import add_builtin_parameters, parameterize_notebook, parameterize_path +from .utils import chdir def execute_notebook( diff --git a/papermill/inspection.py b/papermill/inspection.py index 69d363ad..36527bb0 100644 --- a/papermill/inspection.py +++ b/papermill/inspection.py @@ -1,7 +1,8 @@ """Deduce parameters of a notebook from the parameters cell.""" -import click from pathlib import Path +import click + from .iorw import get_pretty_path, load_notebook_node, local_file_io_cwd from .log import logger from .parameterize import add_builtin_parameters, parameterize_path diff --git a/papermill/iorw.py b/papermill/iorw.py index 45d86f3f..653d9bbe 100644 --- a/papermill/iorw.py +++ b/papermill/iorw.py @@ -1,18 +1,16 @@ +import fnmatch +import json import os import sys -import json -import yaml -import fnmatch -import nbformat -import requests import warnings -import entrypoints - from contextlib import contextmanager +import entrypoints +import nbformat +import requests +import yaml from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential -from . import __version__ from .exceptions import ( PapermillException, PapermillRateLimitException, @@ -21,6 +19,7 @@ ) from .log import logger from .utils import chdir +from .version import version as __version__ try: from .s3 import S3 @@ -48,7 +47,7 @@ GCSFileSystem = missing_dependency_generator("gcsfs", "gcs") try: - from pyarrow.fs import HadoopFileSystem, FileSelector + from pyarrow.fs import FileSelector, HadoopFileSystem except ImportError: HadoopFileSystem = missing_dependency_generator("pyarrow", "hdfs") diff --git a/papermill/parameterize.py b/papermill/parameterize.py index 4e09dfd6..b2422487 100644 --- a/papermill/parameterize.py +++ b/papermill/parameterize.py @@ -1,15 +1,15 @@ +from datetime import datetime +from uuid import uuid4 + import nbformat from .engines import papermill_engines -from .log import logger from .exceptions import PapermillMissingParameterException from .iorw import read_yaml_file +from .log import logger from .translators import translate_parameters from .utils import find_first_tagged_cell_index -from uuid import uuid4 -from datetime import datetime - def add_builtin_parameters(parameters): """Add built-in parameters to a dictionary of parameters diff --git a/papermill/s3.py b/papermill/s3.py index be05e3d0..04b61627 100644 --- a/papermill/s3.py +++ b/papermill/s3.py @@ -1,8 +1,7 @@ """Utilities for working with S3.""" -import os - import logging +import os import threading import zlib @@ -11,7 +10,6 @@ from .exceptions import AwsError from .utils import retry - logger = logging.getLogger('papermill.s3') diff --git a/papermill/tests/__init__.py b/papermill/tests/__init__.py index b1bfa363..fdd395ed 100644 --- a/papermill/tests/__init__.py +++ b/papermill/tests/__init__.py @@ -1,8 +1,5 @@ import os -from io import StringIO - - kernel_name = 'python3' diff --git a/papermill/tests/test_abs.py b/papermill/tests/test_abs.py index b027beeb..57dff73f 100644 --- a/papermill/tests/test_abs.py +++ b/papermill/tests/test_abs.py @@ -1,8 +1,9 @@ import os import unittest - from unittest.mock import Mock, patch + from azure.identity import EnvironmentCredential + from ..abs import AzureBlobStore diff --git a/papermill/tests/test_adl.py b/papermill/tests/test_adl.py index 5dfe9f9b..454f38fb 100644 --- a/papermill/tests/test_adl.py +++ b/papermill/tests/test_adl.py @@ -1,8 +1,9 @@ import unittest +from unittest.mock import MagicMock, Mock, patch -from unittest.mock import Mock, MagicMock, patch - -from ..adl import ADL, core as adl_core, lib as adl_lib +from ..adl import ADL +from ..adl import core as adl_core +from ..adl import lib as adl_lib class ADLTest(unittest.TestCase): diff --git a/papermill/tests/test_autosave.py b/papermill/tests/test_autosave.py index 6c4054c5..74ae06e8 100644 --- a/papermill/tests/test_autosave.py +++ b/papermill/tests/test_autosave.py @@ -1,15 +1,15 @@ -import nbformat import os import tempfile import time import unittest from unittest.mock import patch -from . import get_notebook_path +import nbformat from .. import engines from ..engines import NotebookExecutionManager from ..execute import execute_notebook +from . import get_notebook_path class TestMidCellAutosave(unittest.TestCase): diff --git a/papermill/tests/test_cli.py b/papermill/tests/test_cli.py index 644b007a..c7ffadaf 100755 --- a/papermill/tests/test_cli.py +++ b/papermill/tests/test_cli.py @@ -2,23 +2,22 @@ """ Test the command line interface """ import os -from pathlib import Path -import sys import subprocess +import sys import tempfile -import uuid -import nbclient - -import nbformat import unittest +import uuid +from pathlib import Path from unittest.mock import patch +import nbclient +import nbformat import pytest from click.testing import CliRunner -from . import get_notebook_path, kernel_name from .. import cli -from ..cli import papermill, _is_int, _is_float, _resolve_type +from ..cli import _is_float, _is_int, _resolve_type, papermill +from . import get_notebook_path, kernel_name @pytest.mark.parametrize( diff --git a/papermill/tests/test_clientwrap.py b/papermill/tests/test_clientwrap.py index a8bfff27..cfa2a81a 100644 --- a/papermill/tests/test_clientwrap.py +++ b/papermill/tests/test_clientwrap.py @@ -1,13 +1,12 @@ -import nbformat import unittest - from unittest.mock import call, patch -from . import get_notebook_path +import nbformat -from ..log import logger -from ..engines import NotebookExecutionManager from ..clientwrap import PapermillNotebookClient +from ..engines import NotebookExecutionManager +from ..log import logger +from . import get_notebook_path class TestPapermillClientWrapper(unittest.TestCase): diff --git a/papermill/tests/test_engines.py b/papermill/tests/test_engines.py index ea5a61db..db5ee17c 100644 --- a/papermill/tests/test_engines.py +++ b/papermill/tests/test_engines.py @@ -1,17 +1,16 @@ import copy -import dateutil import unittest - from abc import ABCMeta -from unittest.mock import Mock, patch, call -from nbformat.notebooknode import NotebookNode +from unittest.mock import Mock, call, patch -from . import get_notebook_path +import dateutil +from nbformat.notebooknode import NotebookNode from .. import engines, exceptions -from ..log import logger +from ..engines import Engine, NBClientEngine, NotebookExecutionManager from ..iorw import load_notebook_node -from ..engines import NotebookExecutionManager, Engine, NBClientEngine +from ..log import logger +from . import get_notebook_path def AnyMock(cls): diff --git a/papermill/tests/test_execute.py b/papermill/tests/test_execute.py index 67d717a3..39a3d6c8 100644 --- a/papermill/tests/test_execute.py +++ b/papermill/tests/test_execute.py @@ -3,20 +3,19 @@ import tempfile import unittest from copy import deepcopy -from unittest.mock import patch, ANY - from functools import partial from pathlib import Path +from unittest.mock import ANY, patch import nbformat from nbformat import validate from .. import engines, translators -from ..log import logger +from ..exceptions import PapermillExecutionError +from ..execute import execute_notebook from ..iorw import load_notebook_node +from ..log import logger from ..utils import chdir -from ..execute import execute_notebook -from ..exceptions import PapermillExecutionError from . import get_notebook_path, kernel_name execute_notebook = partial(execute_notebook, kernel_name=kernel_name) diff --git a/papermill/tests/test_inspect.py b/papermill/tests/test_inspect.py index 22160225..f2b476c1 100644 --- a/papermill/tests/test_inspect.py +++ b/papermill/tests/test_inspect.py @@ -6,7 +6,6 @@ from papermill.inspection import display_notebook_help, inspect_notebook - NOTEBOOKS_PATH = Path(__file__).parent / "notebooks" diff --git a/papermill/tests/test_iorw.py b/papermill/tests/test_iorw.py index 6134d1e4..f5d6ae66 100644 --- a/papermill/tests/test_iorw.py +++ b/papermill/tests/test_iorw.py @@ -1,28 +1,28 @@ +import io import json -import unittest import os -import io +import unittest +from tempfile import TemporaryDirectory +from unittest.mock import Mock, patch + import nbformat import pytest - from requests.exceptions import ConnectionError -from tempfile import TemporaryDirectory -from unittest.mock import Mock, patch from .. import iorw +from ..exceptions import PapermillException from ..iorw import ( + ADLHandler, HttpHandler, LocalHandler, NoIOHandler, - ADLHandler, NotebookNodeHandler, - StreamHandler, PapermillIO, - read_yaml_file, - papermill_io, + StreamHandler, local_file_io_cwd, + papermill_io, + read_yaml_file, ) -from ..exceptions import PapermillException from . import get_notebook_path FIXTURE_PATH = os.path.join(os.path.dirname(__file__), 'fixtures') diff --git a/papermill/tests/test_parameterize.py b/papermill/tests/test_parameterize.py index d462da95..431caa12 100644 --- a/papermill/tests/test_parameterize.py +++ b/papermill/tests/test_parameterize.py @@ -1,10 +1,10 @@ import unittest +from datetime import datetime -from ..iorw import load_notebook_node from ..exceptions import PapermillMissingParameterException -from ..parameterize import parameterize_notebook, parameterize_path, add_builtin_parameters +from ..iorw import load_notebook_node +from ..parameterize import add_builtin_parameters, parameterize_notebook, parameterize_path from . import get_notebook_path -from datetime import datetime class TestNotebookParametrizing(unittest.TestCase): diff --git a/papermill/tests/test_s3.py b/papermill/tests/test_s3.py index 817fa725..d19e025b 100644 --- a/papermill/tests/test_s3.py +++ b/papermill/tests/test_s3.py @@ -1,13 +1,13 @@ # The following tests are purposely limited to the exposed interface by iorw.py import os.path -import pytest + import boto3 import moto - +import pytest from moto import mock_s3 -from ..s3 import Bucket, Prefix, Key, S3 +from ..s3 import S3, Bucket, Key, Prefix @pytest.fixture @@ -156,7 +156,7 @@ def test_s3_defaults(): with open(os.path.join(local_dir, test_file_path)) as f: test_nb_content = f.read() -no_empty_lines = lambda s: "\n".join([l for l in s.split('\n') if len(l) > 0]) +no_empty_lines = lambda s: "\n".join([ln for ln in s.split('\n') if ln]) test_clean_nb_content = no_empty_lines(test_nb_content) read_from_gen = lambda g: "\n".join(g) diff --git a/papermill/tests/test_translators.py b/papermill/tests/test_translators.py index 468a0a7d..232630ae 100644 --- a/papermill/tests/test_translators.py +++ b/papermill/tests/test_translators.py @@ -1,8 +1,7 @@ -import pytest - -from unittest.mock import Mock from collections import OrderedDict +from unittest.mock import Mock +import pytest from nbformat.v4 import new_code_cell from .. import translators diff --git a/papermill/tests/test_utils.py b/papermill/tests/test_utils.py index 7b6f8d59..4e24ce75 100644 --- a/papermill/tests/test_utils.py +++ b/papermill/tests/test_utils.py @@ -1,20 +1,19 @@ -import pytest import warnings - -from unittest.mock import Mock, call -from tempfile import TemporaryDirectory from pathlib import Path +from tempfile import TemporaryDirectory +from unittest.mock import Mock, call -from nbformat.v4 import new_notebook, new_code_cell +import pytest +from nbformat.v4 import new_code_cell, new_notebook +from ..exceptions import PapermillParameterOverwriteWarning from ..utils import ( any_tagged_cell, - retry, chdir, merge_kwargs, remove_args, + retry, ) -from ..exceptions import PapermillParameterOverwriteWarning def test_no_tagged_cell(): diff --git a/papermill/translators.py b/papermill/translators.py index fcb68a23..1002cf7b 100644 --- a/papermill/translators.py +++ b/papermill/translators.py @@ -6,7 +6,6 @@ from .exceptions import PapermillException from .models import Parameter - logger = logging.getLogger(__name__) @@ -83,7 +82,7 @@ def translate_list(cls, val): @classmethod def translate(cls, val): - """Translate each of the standard json/yaml types to appropiate objects.""" + """Translate each of the standard json/yaml types to appropriate objects.""" if val is None: return cls.translate_none(val) elif isinstance(val, str): diff --git a/papermill/utils.py b/papermill/utils.py index a12ee308..f7db55c1 100644 --- a/papermill/utils.py +++ b/papermill/utils.py @@ -1,7 +1,6 @@ -import os import logging +import os import warnings - from contextlib import contextmanager from functools import wraps diff --git a/pyproject.toml b/pyproject.toml index 5ef02cd0..4aa6e16c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,68 @@ +# Migration to pyproject.toml is in progress + +# distutils is deprecated and removed in Python 3.12. +# This block can be removed after the build parameters are added to this file +[tool.distutils.bdist_wheel] +universal = true + # Example configuration for Black. [tool.black] line-length = 120 target-version = ['py311'] skip-string-normalization = true + + +[tool.coverage.run] +branch = false + +[tool.coverage.report] +exclude_lines = [ + "if self.debug:", + "pragma: no cover", + "raise AssertionError", + "raise NotImplementedError", + "if __name__ == .__main__.:", +] +omit = [ + "papermill/tests/*", + "papermill/version.py" +] + + +[tool.codespell] +quiet-level = 3 +# comma separated list of words; waiting for: +# https://github.com/codespell-project/codespell/issues/2839#issuecomment-1731601603 +# also adding links until they ignored by its: nature +# https://github.com/codespell-project/codespell/issues/2243#issuecomment-1732019960 +ignore-words-list = "dne, compiletime" + + +[tool.ruff] +line-length = 120 +# Enable Pyflakes `E` and `F` codes by default. +select = [ + "E", "W", # see: https://pypi.org/project/pycodestyle + "F", # see: https://pypi.org/project/pyflakes + "I", # isort +# "D", # see: https://pypi.org/project/pydocstyle +# "N", # see: https://pypi.org/project/pep8-naming +] +#extend-select = [ +# "C4", # see: https://pypi.org/project/flake8-comprehensions +# "SIM", # see: https://pypi.org/project/flake8-simplify +# "RET", # see: https://pypi.org/project/flake8-return +# "PT", # see: https://pypi.org/project/flake8-pytest-style +#] +ignore = [ + "E731", # Do not assign a lambda expression, use a def +] +# Exclude a variety of commonly ignored directories. +exclude = [ + "docs" +] +ignore-init-module-imports = true + +[tool.ruff.pydocstyle] +# Use Google-style docstrings. +convention = "google" diff --git a/requirements/dev.txt b/requirements/dev.txt index dca04012..f8274f23 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -15,7 +15,6 @@ requests >= 2.21.0 check-manifest attrs>=17.4.0 pre-commit -flake8 tox bumpversion recommonmark diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0b0c6c37..00000000 --- a/setup.cfg +++ /dev/null @@ -1,47 +0,0 @@ - -[flake8] -# References: -# https://flake8.readthedocs.io/en/latest/user/configuration.html -# https://flake8.readthedocs.io/en/latest/user/error-codes.html - -# Note: there cannot be spaces after comma's here -exclude = __init__.py -ignore = - # Extra space in brackets - E20, - # Multiple spaces around "," - E231,E241, - # Comments - E26, - # Import formatting - E4, - # Comparing types instead of isinstance - E721, - # Assigning lambda expression - E731, - # Do not use variables named ‘l’, ‘O’, or ‘I’ - E741 -max-line-length = 120 -max-complexity = 23 - -[bdist_wheel] -universal=0 - -[coverage:run] -branch = False -omit = - papermill/tests/* - papermill/version.py - -[coverage:report] -exclude_lines = - if self\.debug: - pragma: no cover - raise AssertionError - raise NotImplementedError - if __name__ == .__main__.: -ignore_errors = True -omit = papermill/tests/*,papermill/version.py - -[tool:pytest] -filterwarnings = always diff --git a/setup.py b/setup.py index 0eb3dbd7..7a4eb315 100644 --- a/setup.py +++ b/setup.py @@ -9,8 +9,8 @@ """ import os -from setuptools import setup +from setuptools import setup local_path = os.path.dirname(__file__) # Fix for tox which manipulates execution pathing