From a95fe54aad559efac711626d54466582f95137bc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Dec 2025 18:02:27 +0000 Subject: [PATCH 1/4] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v5.0.0...v6.0.0) - [github.com/astral-sh/ruff-pre-commit: v0.12.4 → v0.14.10](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.4...v0.14.10) - [github.com/kynan/nbstripout: 0.8.1 → 0.8.2](https://github.com/kynan/nbstripout/compare/0.8.1...0.8.2) - [github.com/executablebooks/mdformat: 0.7.22 → 1.0.0](https://github.com/executablebooks/mdformat/compare/0.7.22...1.0.0) - [github.com/executablebooks/mdformat: 0.7.22 → 1.0.0](https://github.com/executablebooks/mdformat/compare/0.7.22...1.0.0) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9143cb1..9730e63 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: v5.0.0 + rev: v6.0.0 hooks: - id: check-added-large-files args: ['--maxkb=25'] @@ -23,16 +23,16 @@ repos: - id: python-use-type-annotations - id: text-unicode-replacement-char - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.4 + rev: v0.14.10 hooks: - id: ruff - id: ruff-format - repo: https://github.com/kynan/nbstripout - rev: 0.8.1 + rev: 0.8.2 hooks: - id: nbstripout - repo: https://github.com/executablebooks/mdformat - rev: 0.7.22 + rev: 1.0.0 hooks: - id: mdformat additional_dependencies: [ @@ -43,7 +43,7 @@ repos: args: [--wrap, "88"] files: (docs/.) - repo: https://github.com/executablebooks/mdformat - rev: 0.7.22 + rev: 1.0.0 hooks: - id: mdformat additional_dependencies: [ From 4bcfb0b2d11cc6d5710c9fbe1ee014da90ddc36b Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Mon, 29 Dec 2025 18:57:06 +0100 Subject: [PATCH 2/4] Fix ty warnings in docs and wrappers --- docs/source/conf.py | 22 +++++++++++++--------- src/pytask_parallel/execute.py | 3 ++- src/pytask_parallel/wrappers.py | 10 +++++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 7c4f503..ea0cb68 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -123,28 +123,32 @@ def linkcode_resolve(domain: str, info: dict[str, str]) -> str | None: # noqa: return None try: - fn = inspect.getsourcefile(inspect.unwrap(obj)) # ty: ignore[invalid-argument-type] + fn = inspect.getsourcefile(inspect.unwrap(obj)) except TypeError: - try: # property - fn = inspect.getsourcefile(inspect.unwrap(obj.fget)) # ty: ignore[possibly-unbound-attribute,invalid-argument-type] - except (AttributeError, TypeError): - fn = None + fget = getattr(obj, "fget", None) + fn = None if fget is None else inspect.getsourcefile(inspect.unwrap(fget)) if not fn: return None try: source, lineno = inspect.getsourcelines(obj) except TypeError: - try: # property - source, lineno = inspect.getsourcelines(obj.fget) # ty: ignore[possibly-unbound-attribute] - except (AttributeError, TypeError): + fget = getattr(obj, "fget", None) + if fget is None: lineno = None + else: + try: + source, lineno = inspect.getsourcelines(fget) + except TypeError: + lineno = None except OSError: lineno = None linespec = f"#L{lineno}-L{lineno + len(source) - 1}" if lineno else "" - fn = os.path.relpath(fn, start=Path(pytask_parallel.__file__).parent) + package_file = pytask_parallel.__file__ + package_root = Path(package_file).parent if package_file else Path.cwd() + fn = os.path.relpath(fn, start=package_root) if "+" in pytask_parallel.__version__: return f"https://github.com/pytask-dev/pytask-parallel/blob/main/src/pytask_parallel/{fn}{linespec}" diff --git a/src/pytask_parallel/execute.py b/src/pytask_parallel/execute.py index f7cea9f..6eb6465 100644 --- a/src/pytask_parallel/execute.py +++ b/src/pytask_parallel/execute.py @@ -6,6 +6,7 @@ import time from typing import TYPE_CHECKING from typing import Any +from typing import cast import cloudpickle from _pytask.node_protocols import PPathNode @@ -209,7 +210,7 @@ def pytask_execute_task(session: Session, task: PTask) -> Future[WrapperResult]: task_module = get_module(task.function, getattr(task, "path", None)) cloudpickle.register_pickle_by_value(task_module) - return wrapper_func.submit( # ty: ignore[possibly-unbound-attribute,invalid-return-type] + return cast("Any", wrapper_func).submit( task=task, console_options=console.options, kwargs=kwargs, diff --git a/src/pytask_parallel/wrappers.py b/src/pytask_parallel/wrappers.py index ad00e10..4936727 100644 --- a/src/pytask_parallel/wrappers.py +++ b/src/pytask_parallel/wrappers.py @@ -13,6 +13,8 @@ from pathlib import Path from typing import TYPE_CHECKING from typing import Any +from typing import Callable +from typing import cast from attrs import define from pytask import PNode @@ -168,9 +170,11 @@ def wrap_task_in_process( # noqa: PLR0913 def rewrap_task_with_coiled_function(task: PTask) -> CoiledFunction: - return functools.wraps(wrap_task_in_process)( - CoiledFunction(wrap_task_in_process, **task.attributes["coiled_kwargs"]) + wrapped = CoiledFunction(wrap_task_in_process, **task.attributes["coiled_kwargs"]) + decorated = functools.wraps(wrap_task_in_process)( + cast("Callable[..., Any]", wrapped) ) + return cast("CoiledFunction", decorated) def _raise_exception_on_breakpoint(*args: Any, **kwargs: Any) -> None: # noqa: ARG001 @@ -203,7 +207,7 @@ def _render_traceback_to_string( ) -> tuple[type[BaseException], BaseException, str]: """Process the exception and convert the traceback to a string.""" traceback = Traceback(exc_info, show_locals=show_locals) - segments = console.render(traceback, options=console_options) + segments = console.render(cast("Any", traceback), options=console_options) text = "".join(segment.text for segment in segments) return (*exc_info[:2], text) # ty: ignore[invalid-return-type] From 88519e78c58f120f38cab12319f6192ac873a89c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Dec 2025 20:45:26 +0000 Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pytask_parallel/wrappers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytask_parallel/wrappers.py b/src/pytask_parallel/wrappers.py index 4936727..d483d3c 100644 --- a/src/pytask_parallel/wrappers.py +++ b/src/pytask_parallel/wrappers.py @@ -13,7 +13,6 @@ from pathlib import Path from typing import TYPE_CHECKING from typing import Any -from typing import Callable from typing import cast from attrs import define @@ -37,6 +36,7 @@ from pytask_parallel.utils import CoiledFunction if TYPE_CHECKING: + from collections.abc import Callable from types import TracebackType from pytask import Mark From 6658d1a65feebda3dff547748ebd0983daf24e64 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Mon, 29 Dec 2025 21:57:32 +0100 Subject: [PATCH 4/4] fix ty check in docs conf --- docs/source/conf.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index ea0cb68..c455c56 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,10 +14,14 @@ from importlib.metadata import version from pathlib import Path from typing import TYPE_CHECKING +from typing import Any +from typing import cast import pytask_parallel if TYPE_CHECKING: + from collections.abc import Callable + import sphinx # ty: ignore[unresolved-import] @@ -100,7 +104,9 @@ # Linkcode, based on numpy doc/source/conf.py -def linkcode_resolve(domain: str, info: dict[str, str]) -> str | None: # noqa: C901 +def linkcode_resolve( # noqa: C901, PLR0911 + domain: str, info: dict[str, str] +) -> str | None: """Determine the URL corresponding to Python object.""" if domain != "py": return None @@ -122,11 +128,13 @@ def linkcode_resolve(domain: str, info: dict[str, str]) -> str | None: # noqa: except AttributeError: # noqa: PERF203 return None - try: - fn = inspect.getsourcefile(inspect.unwrap(obj)) - except TypeError: - fget = getattr(obj, "fget", None) - fn = None if fget is None else inspect.getsourcefile(inspect.unwrap(fget)) + obj_for_source = obj if callable(obj) else getattr(obj, "fget", None) + if not callable(obj_for_source): + return None + + fn = inspect.getsourcefile( + inspect.unwrap(cast("Callable[..., Any]", obj_for_source)) + ) if not fn: return None