diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7f57331..07b5831 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-added-large-files args: ['--maxkb=25'] @@ -31,24 +31,15 @@ repos: rev: v2.5.0 hooks: - id: setup-cfg-fmt -- repo: https://github.com/psf/black - rev: 23.9.1 - hooks: - - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.292 + rev: v0.1.6 hooks: - id: ruff + - id: ruff-format - repo: https://github.com/dosisod/refurb - rev: v1.21.0 + rev: v1.24.0 hooks: - id: refurb - args: [--ignore, FURB126] -- repo: https://github.com/econchick/interrogate - rev: 1.5.0 - hooks: - - id: interrogate - args: [-v, --fail-under=40, src, tests] - repo: https://github.com/executablebooks/mdformat rev: 0.7.17 hooks: @@ -63,7 +54,7 @@ repos: hooks: - id: codespell - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v1.5.1' + rev: 'v1.7.1' hooks: - id: mypy args: [ @@ -85,7 +76,7 @@ repos: hooks: - id: check-manifest args: [--no-build-isolation] - additional_dependencies: [setuptools-scm, toml] + additional_dependencies: [setuptools-scm, toml, wheel] - repo: meta hooks: - id: check-hooks-apply diff --git a/pyproject.toml b/pyproject.toml index 180b950..254adc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,38 +29,20 @@ target-version = "py38" select = ["ALL"] fix = true extend-ignore = [ + "I", # ignore isort "TRY", # ignore tryceratops. "TCH", # ignore non-guarded type imports. - # Numpy docstyle - "D107", - "D203", - "D212", - "D213", - "D402", - "D413", - "D415", - "D416", - "D417", # Others. - "D404", # Do not start module docstring with "This". - "RET504", # unnecessary variable assignment before return. - "S101", # raise errors for asserts. - "B905", # strict parameter for zip that was implemented in py310. - "I", # ignore isort "ANN101", # type annotating self "ANN102", # type annotating cls - "FBT", # flake8-boolean-trap - "EM", # flake8-errmsg "ANN401", # flake8-annotate typing.Any - "PD", # pandas-vet - "COM812", # trailing comma missing, but black takes care of that - "D401", # imperative mood for first line. too many false-positives. - "SLF001", # access private members. + "COM812", # Comply with ruff-format. + "ISC001", # Comply with ruff-format. ] [tool.ruff.per-file-ignores] -"tests/*" = ["D", "ANN", "PLR2004"] +"tests/*" = ["D", "ANN", "PLR2004", "S101"] [tool.ruff.pydocstyle] diff --git a/src/pytask_parallel/__init__.py b/src/pytask_parallel/__init__.py index 9ddfe07..b940c76 100644 --- a/src/pytask_parallel/__init__.py +++ b/src/pytask_parallel/__init__.py @@ -1,4 +1,4 @@ -"""This module is the main namespace of the package.""" +"""Contains the main namespace of the package.""" from __future__ import annotations try: diff --git a/src/pytask_parallel/backends.py b/src/pytask_parallel/backends.py index 513a04d..981f2a0 100644 --- a/src/pytask_parallel/backends.py +++ b/src/pytask_parallel/backends.py @@ -1,4 +1,4 @@ -"""This module configures the available backends.""" +"""Configures the available backends.""" from __future__ import annotations import enum @@ -23,7 +23,10 @@ class CloudpickleProcessPoolExecutor(ProcessPoolExecutor): # The type signature is wrong for version above Py3.7. Fix when 3.7 is deprecated. def submit( # type: ignore[override] - self, fn: Callable[..., Any], *args: Any, **kwargs: Any # noqa: ARG002 + self, + fn: Callable[..., Any], + *args: Any, # noqa: ARG002 + **kwargs: Any, ) -> Future[Any]: """Submit a new task.""" return super().submit( diff --git a/src/pytask_parallel/config.py b/src/pytask_parallel/config.py index f87df89..cf840a5 100644 --- a/src/pytask_parallel/config.py +++ b/src/pytask_parallel/config.py @@ -17,7 +17,7 @@ def pytask_parse_config(config: dict[str, Any]) -> None: if ( isinstance(config["parallel_backend"], str) - and config["parallel_backend"] in ParallelBackend._value2member_map_ + and config["parallel_backend"] in ParallelBackend._value2member_map_ # noqa: SLF001 ): config["parallel_backend"] = ParallelBackend(config["parallel_backend"]) elif ( @@ -26,7 +26,8 @@ def pytask_parse_config(config: dict[str, Any]) -> None: ): pass else: - raise ValueError("Invalid value for 'parallel_backend'.") + msg = f"Invalid value for 'parallel_backend'. Got {config['parallel_backend']}." + raise ValueError(msg) config["delay"] = 0.1 diff --git a/src/pytask_parallel/execute.py b/src/pytask_parallel/execute.py index 70886e3..c3f2ed8 100644 --- a/src/pytask_parallel/execute.py +++ b/src/pytask_parallel/execute.py @@ -211,11 +211,12 @@ def pytask_execute_task(session: Session, task: PTask) -> Future[Any] | None: def _raise_exception_on_breakpoint(*args: Any, **kwargs: Any) -> None: # noqa: ARG001 - raise RuntimeError( + msg = ( "You cannot use 'breakpoint()' or 'pdb.set_trace()' while parallelizing the " "execution of tasks with pytask-parallel. Please, remove the breakpoint or run " "the task without parallelization to debug it." ) + raise RuntimeError(msg) def _patch_set_trace_and_breakpoint() -> None: @@ -235,7 +236,7 @@ def _patch_set_trace_and_breakpoint() -> None: def _execute_task( # noqa: PLR0913 task: PTask, kwargs: dict[str, Any], - show_locals: bool, + show_locals: bool, # noqa: FBT001 console_options: ConsoleOptions, session_filterwarnings: tuple[str, ...], task_filterwarnings: tuple[Mark, ...], @@ -251,7 +252,7 @@ def _execute_task( # noqa: PLR0913 with warnings.catch_warnings(record=True) as log: # mypy can't infer that record=True means log is not None; help it. - assert log is not None + assert log is not None # noqa: S101 for arg in session_filterwarnings: warnings.filterwarnings(*parse_warning_filter(arg, escape=False)) @@ -284,7 +285,7 @@ def _execute_task( # noqa: PLR0913 nodes = tree_leaves(task.produces["return"]) values = structure_return.flatten_up_to(out) for node, value in zip(nodes, values): - node.save(value) # type: ignore[attr-defined] + node.save(value) processed_exc_info = None @@ -305,7 +306,7 @@ def _execute_task( # noqa: PLR0913 def _process_exception( exc_info: tuple[type[BaseException], BaseException, TracebackType | None], - show_locals: bool, + show_locals: bool, # noqa: FBT001 console_options: ConsoleOptions, ) -> tuple[type[BaseException], BaseException, str]: """Process the exception and convert the traceback to a string."""