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) 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/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/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/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]): 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)