From cca296faf3165932a031af8080c574a5d5242c6e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:54:19 +0000 Subject: [PATCH 1/9] [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.12 → v0.12.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.12...v0.12.0) - [github.com/crate-ci/typos: v1.32.0 → v1](https://github.com/crate-ci/typos/compare/v1.32.0...v1) --- .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 b9ccf5ca..95550a1a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: - id: python-no-log-warn - id: text-unicode-replacement-char - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.12 + rev: v0.12.0 hooks: - id: ruff-format - id: ruff @@ -58,7 +58,7 @@ repos: - id: nbstripout exclude: (docs) - repo: https://github.com/crate-ci/typos - rev: v1.32.0 + rev: v1 hooks: - id: typos exclude: (\.ipynb) From 71233d660a1773ed2210f6b1b00d82ebecd11b0f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:54:59 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytask/cache.py | 2 +- src/_pytask/mark/expression.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/_pytask/cache.py b/src/_pytask/cache.py index a7a1f3c7..b8e280a1 100644 --- a/src/_pytask/cache.py +++ b/src/_pytask/cache.py @@ -72,7 +72,7 @@ def _make_memoize_key( if kwargs: for i, arg in enumerate(argspec.args): if arg in kwargs: - args = args[:i] + (kwargs.pop(arg),) + args[i:] + args = (*args[:i], kwargs.pop(arg), *args[i:]) if args: key_args += args diff --git a/src/_pytask/mark/expression.py b/src/_pytask/mark/expression.py index 5300c15d..06700a26 100644 --- a/src/_pytask/mark/expression.py +++ b/src/_pytask/mark/expression.py @@ -179,7 +179,8 @@ def not_expr(s: Scanner) -> ast.expr: ident = s.accept(TokenType.IDENT) if ident: return ast.Name(IDENT_PREFIX + ident.value, ast.Load()) - s.reject((TokenType.NOT, TokenType.LPAREN, TokenType.IDENT)) # noqa: RET503 + s.reject((TokenType.NOT, TokenType.LPAREN, TokenType.IDENT)) + return None class MatcherAdapter(Mapping[str, bool]): From ba9a0d3741144ba429e6be9976b577e5ed146713 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 28 Jun 2025 20:18:47 +0200 Subject: [PATCH 3/9] Fix. --- src/_pytask/build.py | 2 +- src/_pytask/dag_command.py | 2 +- src/_pytask/debugging.py | 4 ++-- src/_pytask/warnings_utils.py | 2 +- tests/test_capture.py | 2 +- tests/test_compat.py | 4 ++-- tests/test_path.py | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/_pytask/build.py b/src/_pytask/build.py index f2d8f7e4..7c912d59 100644 --- a/src/_pytask/build.py +++ b/src/_pytask/build.py @@ -222,7 +222,7 @@ def build( # noqa: C901, PLR0912, PLR0913 if "command" not in raw_config: raw_config["command"] = "build" # Add defaults from cli. - from _pytask.cli import DEFAULTS_FROM_CLI + from _pytask.cli import DEFAULTS_FROM_CLI # noqa: PLC0415 raw_config = {**DEFAULTS_FROM_CLI, **raw_config} diff --git a/src/_pytask/dag_command.py b/src/_pytask/dag_command.py index 3f14357b..3c5ac1ec 100644 --- a/src/_pytask/dag_command.py +++ b/src/_pytask/dag_command.py @@ -151,7 +151,7 @@ def build_dag(raw_config: dict[str, Any]) -> nx.DiGraph: if "command" not in raw_config: raw_config["command"] = "dag" # Add defaults from cli. - from _pytask.cli import DEFAULTS_FROM_CLI + from _pytask.cli import DEFAULTS_FROM_CLI # noqa: PLC0415 raw_config = {**DEFAULTS_FROM_CLI, **raw_config} diff --git a/src/_pytask/debugging.py b/src/_pytask/debugging.py index bec231a3..0ac3d62c 100644 --- a/src/_pytask/debugging.py +++ b/src/_pytask/debugging.py @@ -133,7 +133,7 @@ def _import_pdb_cls( ) -> type[pdb.Pdb]: """Create a debugger from an imported class.""" if not cls._config: - import pdb # noqa: T100 + import pdb # noqa: PLC0415, T100 # Happens when using pytask.set_trace outside of a task. return pdb.Pdb @@ -160,7 +160,7 @@ def _import_pdb_cls( msg = f"--pdbcls: could not import {value!r}: {exc}." raise ValueError(msg) from exc else: - import pdb # noqa: T100 + import pdb # noqa: PLC0415, T100 pdb_cls = pdb.Pdb diff --git a/src/_pytask/warnings_utils.py b/src/_pytask/warnings_utils.py index eb198f62..b7528353 100644 --- a/src/_pytask/warnings_utils.py +++ b/src/_pytask/warnings_utils.py @@ -119,7 +119,7 @@ def _resolve_warning_category(category: str) -> type[Warning]: return Warning if "." not in category: - import builtins as m + import builtins as m # noqa: PLC0415 klass = category else: diff --git a/tests/test_capture.py b/tests/test_capture.py index 1d57b6bc..e0c0f6b2 100644 --- a/tests/test_capture.py +++ b/tests/test_capture.py @@ -398,7 +398,7 @@ def test_unicode_and_str_mixture(self): def test_dontreadfrominput(): - from _pytest.capture import DontReadFromInput + from _pytest.capture import DontReadFromInput # noqa: PLC0415 f = DontReadFromInput() assert f.buffer is f diff --git a/tests/test_compat.py b/tests/test_compat.py index 08e72fe8..10bc0f26 100644 --- a/tests/test_compat.py +++ b/tests/test_compat.py @@ -109,7 +109,7 @@ def test_bad_version(monkeypatch): result = import_optional_dependency("fakemodule", min_version="0.8") assert result is module - with pytest.warns(UserWarning): + with pytest.warns(UserWarning, match=match): result = import_optional_dependency("fakemodule", errors="warn") assert result is None @@ -134,7 +134,7 @@ def test_submodule(monkeypatch): with pytest.raises(ImportError, match=match): import_optional_dependency("fakemodule.submodule") - with pytest.warns(UserWarning): + with pytest.warns(UserWarning, match=match): result = import_optional_dependency("fakemodule.submodule", errors="warn") assert result is None diff --git a/tests/test_path.py b/tests/test_path.py index 4a285f07..8cc9ba7c 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -164,7 +164,7 @@ def test_no_meta_path_found( assert module.foo(2) == 42 # type: ignore[attr-defined] # mode='importlib' fails if no spec is found to load the module - import importlib.util + import importlib.util # noqa: PLC0415 # Force module to be re-imported. del sys.modules[module.__name__] @@ -269,7 +269,7 @@ class Data: ) ) - import pickle + import pickle # noqa: PLC0415 def round_trip(obj): s = pickle.dumps(obj) From cf2c6a8d044084e38ec199821293369c4eaad40f 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:01 +0000 Subject: [PATCH 4/9] [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.12.1 → v0.12.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.1...v0.12.4) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4b6b5dc8..7ed6f3cb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: - id: python-no-log-warn - id: text-unicode-replacement-char - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.1 + rev: v0.12.4 hooks: - id: ruff-format - id: ruff From 6b1ee7ecb556b0741533e89172ffd58f17df62bd Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 25 Jul 2025 17:12:15 +0200 Subject: [PATCH 5/9] Flaky test. --- tests/test_dag_command.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_dag_command.py b/tests/test_dag_command.py index 3ca41baf..458546f3 100644 --- a/tests/test_dag_command.py +++ b/tests/test_dag_command.py @@ -62,6 +62,9 @@ def task_example(path=Path("input.txt")): ... @pytest.mark.skipif(not _TEST_SHOULD_RUN, reason="pygraphviz is required") +@pytest.mark.xfail( + sys.platform == "linux" and sys.version_info[:2] == (3, 9), reason="flakey" +) @pytest.mark.parametrize("layout", _GRAPH_LAYOUTS) @pytest.mark.parametrize("format_", _TEST_FORMATS) @pytest.mark.parametrize("rankdir", [_RankDirection.LR.value, _RankDirection.TB]) From 16b4dfc3d31ade54a9148fbd6751cd521adf2e14 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 17:57:38 +0000 Subject: [PATCH 6/9] [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.13.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.4...v0.13.2) - [github.com/crate-ci/typos: v1.34.0 → v1](https://github.com/crate-ci/typos/compare/v1.34.0...v1) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 664e556e..b3b32647 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'] @@ -25,7 +25,7 @@ repos: - id: python-no-log-warn - id: text-unicode-replacement-char - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.4 + rev: v0.13.2 hooks: - id: ruff-format - id: ruff-check @@ -55,7 +55,7 @@ repos: - id: nbstripout exclude: (docs) - repo: https://github.com/crate-ci/typos - rev: v1.34.0 + rev: v1 hooks: - id: typos exclude: (\.ipynb) From 58bc054904d6f99b57566c05a5a3c43436b61e2f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 17:58:13 +0000 Subject: [PATCH 7/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytask/click.py | 2 +- tests/test_capture.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/_pytask/click.py b/src/_pytask/click.py index 10a16867..eb79e211 100644 --- a/src/_pytask/click.py +++ b/src/_pytask/click.py @@ -186,7 +186,7 @@ def parse_args(self, ctx: Context, args: list[str]) -> list[str]: opts, args, param_order = parser.parse_args(args=args) for param in _iter_params_for_processing(param_order, self.get_params(ctx)): - value, args = param.handle_parse_result(ctx, opts, args) + _value, args = param.handle_parse_result(ctx, opts, args) if args and not ctx.allow_extra_args and not ctx.resilient_parsing: ctx.fail( diff --git a/tests/test_capture.py b/tests/test_capture.py index e0c0f6b2..ed81ca7d 100644 --- a/tests/test_capture.py +++ b/tests/test_capture.py @@ -196,7 +196,7 @@ def test_capturing_basic_api(self, method): capman.resume() print("hello") capman.suspend() - out, err = capman.read() + out, _err = capman.read() if method != CaptureMethod.NO: assert out == "hello\n" capman.stop_capturing() @@ -624,7 +624,7 @@ def test_capture_results_accessible_by_attribute(self): def test_capturing_readouterr_unicode(self): with self.getcapture() as cap: print("hxąć") - out, err = cap.readouterr() + out, _err = cap.readouterr() assert out == "hxąć\n" def test_reset_twice_error(self): @@ -656,8 +656,8 @@ def test_capturing_error_recursive(self): print("cap1") with self.getcapture() as cap2: print("cap2") - out2, err2 = cap2.readouterr() - out1, err1 = cap1.readouterr() + out2, _err2 = cap2.readouterr() + out1, _err1 = cap1.readouterr() assert out1 == "cap1\n" assert out2 == "cap2\n" @@ -702,8 +702,8 @@ def test_capturing_error_recursive(self): print("cap1") with self.getcapture() as cap2: print("cap2") - out2, err2 = cap2.readouterr() - out1, err1 = cap1.readouterr() + out2, _err2 = cap2.readouterr() + out1, _err1 = cap1.readouterr() assert out1 == "cap1\ncap2\n" assert out2 == "cap2\n" From 9912c18f751bf31cbdde40002cd214e307e4503f Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 Oct 2025 10:51:38 +0200 Subject: [PATCH 8/9] Fix. --- pyproject.toml | 1 - tests/test_capture.py | 2 +- tests/test_compat.py | 2 +- tests/test_dag_utils.py | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d76c64a9..17d9f8fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -122,7 +122,6 @@ ignore = [ "COM812", # Comply with ruff-format. "ISC001", # Comply with ruff-format. "FBT", - "PD901", # Avoid generic df for dataframes. "S101", # raise errors for asserts. "S603", # Call check with subprocess.run. "S607", # Call subprocess.run with partial executable path. diff --git a/tests/test_capture.py b/tests/test_capture.py index e0c0f6b2..cf86ba26 100644 --- a/tests/test_capture.py +++ b/tests/test_capture.py @@ -188,7 +188,7 @@ def test_capturing_basic_api(self, method): assert outerr == ("", "") print("hello") capman.suspend() - out, err = capman.read() + out, _err = capman.read() if method == CaptureMethod.NO: assert old == (sys.stdout, sys.stderr, sys.stdin) else: diff --git a/tests/test_compat.py b/tests/test_compat.py index 10bc0f26..df4aaf9f 100644 --- a/tests/test_compat.py +++ b/tests/test_compat.py @@ -149,5 +149,5 @@ def test_no_version_raises(monkeypatch): sys.modules[name] = module monkeypatch.setitem(_MINIMUM_VERSIONS, name, "1.0.0") - with pytest.raises(ImportError, match="Can't determine .* fakemodule"): + with pytest.raises(ImportError, match=r"Can't determine .* fakemodule"): import_optional_dependency(name) diff --git a/tests/test_dag_utils.py b/tests/test_dag_utils.py index aaeefa41..a33c04c7 100644 --- a/tests/test_dag_utils.py +++ b/tests/test_dag_utils.py @@ -153,7 +153,7 @@ def test_raise_error_for_cycle_in_graph(dag): "115f685b0af2aef0c7317a0b48562f34cfb7a622549562bd3d34d4d948b4fdab", "55c6cef62d3e62d5f8fc65bb846e66d8d0d3ca60608c04f6f7b095ea073a7dcf", ) - with pytest.raises(ValueError, match="The DAG contains cycles."): + with pytest.raises(ValueError, match=r"The DAG contains cycles\."): TopologicalSorter.from_dag(dag) From 3c2134e12b97ce4d86a85eaea3b9754eb07333c8 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 Oct 2025 10:52:36 +0200 Subject: [PATCH 9/9] FIx. --- src/_pytask/build.py | 2 +- src/_pytask/collect_command.py | 2 +- src/_pytask/dag_command.py | 4 ++-- src/_pytask/mark/__init__.py | 2 +- src/_pytask/profile.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/_pytask/build.py b/src/_pytask/build.py index 7c912d59..b5ccf0bf 100644 --- a/src/_pytask/build.py +++ b/src/_pytask/build.py @@ -254,7 +254,7 @@ def build( # noqa: C901, PLR0912, PLR0913 session = Session.from_config(config_) - except (ConfigurationError, Exception): + except (ConfigurationError, Exception): # noqa: BLE001 console.print(Traceback(sys.exc_info())) session = Session(exit_code=ExitCode.CONFIGURATION_FAILED) diff --git a/src/_pytask/collect_command.py b/src/_pytask/collect_command.py index 2e953e5c..6b7b8f6a 100644 --- a/src/_pytask/collect_command.py +++ b/src/_pytask/collect_command.py @@ -63,7 +63,7 @@ def collect(**raw_config: Any | None) -> NoReturn: config = pm.hook.pytask_configure(pm=pm, raw_config=raw_config) session = Session.from_config(config) - except (ConfigurationError, Exception): # pragma: no cover + except (ConfigurationError, Exception): # noqa: BLE001 # pragma: no cover session = Session(exit_code=ExitCode.CONFIGURATION_FAILED) console.print_exception() diff --git a/src/_pytask/dag_command.py b/src/_pytask/dag_command.py index 3c5ac1ec..8127735f 100644 --- a/src/_pytask/dag_command.py +++ b/src/_pytask/dag_command.py @@ -87,7 +87,7 @@ def dag(**raw_config: Any) -> int: config = pm.hook.pytask_configure(pm=pm, raw_config=raw_config) session = Session.from_config(config) - except (ConfigurationError, Exception): # pragma: no cover + except (ConfigurationError, Exception): # noqa: BLE001 # pragma: no cover console.print_exception() session = Session(exit_code=ExitCode.CONFIGURATION_FAILED) @@ -183,7 +183,7 @@ def build_dag(raw_config: dict[str, Any]) -> nx.DiGraph: session = Session.from_config(config) - except (ConfigurationError, Exception): # pragma: no cover + except (ConfigurationError, Exception): # noqa: BLE001 # pragma: no cover console.print_exception() session = Session(exit_code=ExitCode.CONFIGURATION_FAILED) diff --git a/src/_pytask/mark/__init__.py b/src/_pytask/mark/__init__.py index e2586a46..9d49b6e0 100644 --- a/src/_pytask/mark/__init__.py +++ b/src/_pytask/mark/__init__.py @@ -59,7 +59,7 @@ def markers(**raw_config: Any) -> NoReturn: config = pm.hook.pytask_configure(pm=pm, raw_config=raw_config) session = Session.from_config(config) - except (ConfigurationError, Exception): # pragma: no cover + except (ConfigurationError, Exception): # noqa: BLE001 # pragma: no cover console.print_exception() session = Session(exit_code=ExitCode.CONFIGURATION_FAILED) diff --git a/src/_pytask/profile.py b/src/_pytask/profile.py index 5063e511..60884708 100644 --- a/src/_pytask/profile.py +++ b/src/_pytask/profile.py @@ -121,7 +121,7 @@ def profile(**raw_config: Any) -> NoReturn: config = pm.hook.pytask_configure(pm=pm, raw_config=raw_config) session = Session.from_config(config) - except (ConfigurationError, Exception): # pragma: no cover + except (ConfigurationError, Exception): # noqa: BLE001 # pragma: no cover session = Session(exit_code=ExitCode.CONFIGURATION_FAILED) console.print(Traceback(sys.exc_info()))