From cc69a3789cace002d6bb77d50ad8abf558bb5176 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 11 Jul 2025 15:36:38 -0700 Subject: [PATCH] chore(deps): update pre-commit hooks (#5745) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update pre-commit hooks updates: - [github.com/pre-commit/mirrors-clang-format: v20.1.5 → v20.1.7](https://github.com/pre-commit/mirrors-clang-format/compare/v20.1.5...v20.1.7) - [github.com/astral-sh/ruff-pre-commit: v0.11.12 → v0.12.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.12...v0.12.2) - [github.com/pre-commit/mirrors-mypy: v1.16.0 → v1.16.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.16.0...v1.16.1) - [github.com/python-jsonschema/check-jsonschema: 0.33.0 → 0.33.2](https://github.com/python-jsonschema/check-jsonschema/compare/0.33.0...0.33.2) * chore: fix new ruff check warnings Signed-off-by: Henry Schreiner * style: pre-commit fixes --------- Signed-off-by: Henry Schreiner Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner --- .pre-commit-config.yaml | 10 +++++----- pyproject.toml | 17 +++++++++-------- tests/conftest.py | 8 ++++++++ tests/test_class_sh_basic.py | 6 ++++-- tests/test_warnings.py | 2 +- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9f67a7191..15eac4586 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,22 +25,22 @@ repos: # Clang format the codebase automatically - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v20.1.5" + rev: "v20.1.7" hooks: - id: clang-format types_or: [c++, c, cuda] # Ruff, the Python auto-correcting linter/formatter written in Rust - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.12 + rev: v0.12.2 hooks: - - id: ruff + - id: ruff-check args: ["--fix", "--show-fixes"] - id: ruff-format # Check static types with mypy - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.16.0" + rev: "v1.16.1" hooks: - id: mypy args: [] @@ -142,7 +142,7 @@ repos: # Check schemas on some of our YAML files - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.33.0 + rev: 0.33.2 hooks: - id: check-readthedocs - id: check-github-workflows diff --git a/pyproject.toml b/pyproject.toml index 93f73748c..a4b43d3b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -143,9 +143,6 @@ messages_control.disable = [ "consider-using-f-string", # triggers in _version.py incorrectly ] -[tool.ruff] -src = ["src"] - [tool.ruff.lint] extend-select = [ "B", # flake8-bugbear @@ -166,17 +163,21 @@ extend-select = [ "YTT", # flake8-2020 ] ignore = [ - "PLR", # Design related pylint - "PT011", # Too broad with raises in pytest - "SIM118", # iter(x) is not always the same as iter(x.keys()) + "PLR", # Design related pylint + "PT011", # Too broad with raises in pytest + "SIM118", # iter(x) is not always the same as iter(x.keys()) + "PLC0415", # We import in functions for various reasons ] -unfixable = ["T20"] isort.known-first-party = ["env", "pybind11_cross_module_tests", "pybind11_tests"] isort.required-imports = ["from __future__ import annotations"] [tool.ruff.lint.per-file-ignores] -"tests/**" = ["EM", "N", "E721"] +"tests/**" = [ + "EM", + "N", + "E721", +] "tests/test_call_policies.py" = ["PLC1901"] [tool.repo-review] diff --git a/tests/conftest.py b/tests/conftest.py index 5f515378b..a2574f166 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -77,6 +77,8 @@ class Output: def __str__(self): return self.string + __hash__ = None + def __eq__(self, other): # Ignore constructor/destructor output which is prefixed with "###" a = [ @@ -94,6 +96,8 @@ class Output: class Unordered(Output): """Custom comparison for output without strict line ordering""" + __hash__ = None + def __eq__(self, other): a = _split_and_sort(self.string) b = _split_and_sort(other) @@ -116,6 +120,8 @@ class Capture: def __exit__(self, *args): self.out, self.err = self.capfd.readouterr() + __hash__ = None + def __eq__(self, other): a = Output(self.out) b = other @@ -155,6 +161,8 @@ class SanitizedString: self.string = self.sanitizer(thing) return self + __hash__ = None + def __eq__(self, other): a = self.string b = _strip_and_dedent(other) diff --git a/tests/test_class_sh_basic.py b/tests/test_class_sh_basic.py index f07253a5d..18f0b0646 100644 --- a/tests/test_class_sh_basic.py +++ b/tests/test_class_sh_basic.py @@ -135,8 +135,9 @@ def test_cannot_disown_use_count_ne_1(pass_f, rtrn_f): assert str(exc_info.value) == ("Cannot disown use_count != 1 (load_as_unique_ptr).") -def test_unique_ptr_roundtrip(num_round_trips=1000): +def test_unique_ptr_roundtrip(): # Multiple roundtrips to stress-test instance registration/deregistration. + num_round_trips = 1000 recycled = m.atyp("passenger") for _ in range(num_round_trips): id_orig = id(recycled) @@ -164,8 +165,9 @@ def test_rtrn_unique_ptr_cref(): assert obj0 is obj1 -def test_unique_ptr_cref_roundtrip(num_round_trips=1000): +def test_unique_ptr_cref_roundtrip(): # Multiple roundtrips to stress-test implementation. + num_round_trips = 1000 orig = m.atyp("passenger") mtxt_orig = m.get_mtxt(orig) recycled = orig diff --git a/tests/test_warnings.py b/tests/test_warnings.py index 4313432c3..e42a8c330 100644 --- a/tests/test_warnings.py +++ b/tests/test_warnings.py @@ -19,7 +19,7 @@ from pybind11_tests import warnings_ as m def test_warning_simple( expected_category, expected_message, expected_value, module_function ): - with pytest.warns(Warning) as excinfo: + with pytest.warns(Warning, match="This is") as excinfo: value = module_function() assert issubclass(excinfo[0].category, expected_category)