From f7f6db3fdb7afad65eeffd1f8a40565c43699004 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 21 Jul 2025 17:56:08 +0000 Subject: [PATCH 1/6] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.6 → v0.12.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.6...v0.12.4) - [github.com/dosisod/refurb: v2.0.0 → v2.1.0](https://github.com/dosisod/refurb/compare/v2.0.0...v2.1.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9bc6dcb..fd2ec75 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,12 +27,12 @@ repos: hooks: - id: sort-all - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.6 + rev: v0.12.4 hooks: - id: ruff - id: ruff-format - repo: https://github.com/dosisod/refurb - rev: v2.0.0 + rev: v2.1.0 hooks: - id: refurb - repo: https://github.com/kynan/nbstripout From 775800a2e022f830fc41f4a94ab431ab8b0602ee Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 26 Jul 2025 12:43:15 +0200 Subject: [PATCH 2/6] Remove sort-all hook as it's covered by ruff --- .pre-commit-config.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fd2ec75..d50a1ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,10 +22,6 @@ repos: - id: python-no-log-warn - id: python-use-type-annotations - id: text-unicode-replacement-char -- repo: https://github.com/aio-libs/sort-all - rev: v1.3.0 - hooks: - - id: sort-all - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.12.4 hooks: From 1efa73959b603a718c1c374dddaf81d8e75ba07d Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 26 Jul 2025 12:49:05 +0200 Subject: [PATCH 3/6] Fix ruff PLC0415 errors and remove deprecated rules - Add per-file ignore for PLC0415 (imports in functions) to allow intentional circular import prevention - Remove deprecated ANN101 and ANN102 rules from ruff configuration - All pre-commit checks now pass --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a067839..a6f621a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,8 +111,6 @@ unsafe-fixes = true [tool.ruff.lint] extend-ignore = [ - "ANN101", # type annotating self - "ANN102", # type annotating cls "ANN401", # flake8-annotate typing.Any "COM812", # Comply with ruff-format. "ISC001", # Comply with ruff-format. @@ -123,6 +121,7 @@ select = ["ALL"] "tests/*" = ["D", "ANN", "PLR2004", "S101"] "docs/source/conf.py" = ["INP001"] "docs_src/*" = ["ARG001", "D", "INP001", "S301"] +"src/pytask_parallel/*.py" = ["PLC0415"] [tool.ruff.lint.isort] force-single-line = true From 749f90de1f6583b075601c385b7d7115adc599b6 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 26 Jul 2025 12:54:15 +0200 Subject: [PATCH 4/6] Fix. --- pyproject.toml | 1 - src/pytask_parallel/backends.py | 2 +- src/pytask_parallel/execute.py | 6 +++--- src/pytask_parallel/utils.py | 2 +- src/pytask_parallel/wrappers.py | 4 ++-- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a6f621a..6f548f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -121,7 +121,6 @@ select = ["ALL"] "tests/*" = ["D", "ANN", "PLR2004", "S101"] "docs/source/conf.py" = ["INP001"] "docs_src/*" = ["ARG001", "D", "INP001", "S301"] -"src/pytask_parallel/*.py" = ["PLC0415"] [tool.ruff.lint.isort] force-single-line = true diff --git a/src/pytask_parallel/backends.py b/src/pytask_parallel/backends.py index a0e0b12..b889118 100644 --- a/src/pytask_parallel/backends.py +++ b/src/pytask_parallel/backends.py @@ -47,7 +47,7 @@ def submit( def _get_dask_executor(n_workers: int) -> Executor: """Get an executor from a dask client.""" _rich_traceback_guard = True - from pytask import import_optional_dependency + from pytask import import_optional_dependency # noqa: PLC0415 distributed = import_optional_dependency("distributed") assert distributed # noqa: S101 diff --git a/src/pytask_parallel/execute.py b/src/pytask_parallel/execute.py index d2e9cd3..0a886e4 100644 --- a/src/pytask_parallel/execute.py +++ b/src/pytask_parallel/execute.py @@ -195,7 +195,7 @@ def pytask_execute_task(session: Session, task: PTask) -> Future[WrapperResult]: if is_coiled_function(task): # Prevent circular import for coiled backend. - from pytask_parallel.wrappers import rewrap_task_with_coiled_function + from pytask_parallel.wrappers import rewrap_task_with_coiled_function # noqa: PLC0415 wrapper_func = rewrap_task_with_coiled_function(task) @@ -219,7 +219,7 @@ def pytask_execute_task(session: Session, task: PTask) -> Future[WrapperResult]: if worker_type == WorkerType.PROCESSES: # Prevent circular import for loky backend. - from pytask_parallel.wrappers import wrap_task_in_process + from pytask_parallel.wrappers import wrap_task_in_process # noqa: PLC0415 # Task modules are dynamically loaded and added to `sys.modules`. Thus, # cloudpickle believes the module of the task function is also importable in the @@ -242,7 +242,7 @@ def pytask_execute_task(session: Session, task: PTask) -> Future[WrapperResult]: if worker_type == WorkerType.THREADS: # Prevent circular import for loky backend. - from pytask_parallel.wrappers import wrap_task_in_thread + from pytask_parallel.wrappers import wrap_task_in_thread # noqa: PLC0415 return session.config["_parallel_executor"].submit( wrap_task_in_thread, task=task, remote=False, **kwargs diff --git a/src/pytask_parallel/utils.py b/src/pytask_parallel/utils.py index 2ab50f5..1db9ab2 100644 --- a/src/pytask_parallel/utils.py +++ b/src/pytask_parallel/utils.py @@ -50,7 +50,7 @@ def parse_future_result( future_exception = future.exception() if future_exception is not None: # Prevent circular import for loky backend. - from pytask_parallel.wrappers import WrapperResult + from pytask_parallel.wrappers import WrapperResult # noqa: PLC0415 exc_info = _parse_future_exception(future_exception) return WrapperResult( diff --git a/src/pytask_parallel/wrappers.py b/src/pytask_parallel/wrappers.py index a7b7d8c..acf6434 100644 --- a/src/pytask_parallel/wrappers.py +++ b/src/pytask_parallel/wrappers.py @@ -189,8 +189,8 @@ def _patch_set_trace_and_breakpoint() -> None: a subprocess and print a better exception message. """ - import pdb # noqa: T100 - import sys + import pdb # noqa: PLC0415, T100 + import sys # noqa: PLC0415 pdb.set_trace = _raise_exception_on_breakpoint sys.breakpointhook = _raise_exception_on_breakpoint From a502556366d78d3de71d3fbb2ea805e4a5b75e6f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 26 Jul 2025 10:59:24 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pytask_parallel/execute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytask_parallel/execute.py b/src/pytask_parallel/execute.py index 0a886e4..85e5edf 100644 --- a/src/pytask_parallel/execute.py +++ b/src/pytask_parallel/execute.py @@ -195,7 +195,7 @@ def pytask_execute_task(session: Session, task: PTask) -> Future[WrapperResult]: if is_coiled_function(task): # Prevent circular import for coiled backend. - from pytask_parallel.wrappers import rewrap_task_with_coiled_function # noqa: PLC0415 + from pytask_parallel.wrappers import rewrap_task_with_coiled_function wrapper_func = rewrap_task_with_coiled_function(task) From 95ad495698e5833c09ebf2a66f3b227e9394fdaa Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 26 Jul 2025 13:01:14 +0200 Subject: [PATCH 6/6] Fix. --- src/pytask_parallel/execute.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pytask_parallel/execute.py b/src/pytask_parallel/execute.py index 85e5edf..84e1858 100644 --- a/src/pytask_parallel/execute.py +++ b/src/pytask_parallel/execute.py @@ -195,7 +195,9 @@ def pytask_execute_task(session: Session, task: PTask) -> Future[WrapperResult]: if is_coiled_function(task): # Prevent circular import for coiled backend. - from pytask_parallel.wrappers import rewrap_task_with_coiled_function + from pytask_parallel.wrappers import ( # noqa: PLC0415 + rewrap_task_with_coiled_function, + ) wrapper_func = rewrap_task_with_coiled_function(task)