From 49aac937f5edb634b7cc89de19b9ba2e07517968 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Apr 2026 21:41:28 +0000 Subject: [PATCH 1/7] [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.15.8 → v0.15.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.8...v0.15.9) - [github.com/pre-commit/mirrors-mypy: v1.19.1 → v1.20.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.19.1...v1.20.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 e3c0cdaca75..3da6a52e66a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ minimum_pre_commit_version: "4.4.0" repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.15.8" + rev: "v0.15.9" hooks: - id: ruff-check args: ["--fix"] @@ -34,7 +34,7 @@ repos: hooks: - id: python-use-type-annotations - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.19.1 + rev: v1.20.0 hooks: - id: mypy files: ^(src/|testing/|scripts/) From b2096f0bf97ba0e2834f8dd019a9679e6f0daf8c Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 7 Apr 2026 08:44:34 +0200 Subject: [PATCH 2/7] remove noqa for fixed mypy fp --- src/_pytest/raises.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/_pytest/raises.py b/src/_pytest/raises.py index 75eea7d8cc9..76199e3df02 100644 --- a/src/_pytest/raises.py +++ b/src/_pytest/raises.py @@ -1482,8 +1482,7 @@ def set_result(self, expected: int, actual: int, result: str | None) -> None: def get_result(self, expected: int, actual: int) -> str | None: res = self.results[actual][expected] assert res is not NotChecked - # mypy doesn't support identity checking against anything but None - return res # type: ignore[return-value] + return res def has_result(self, expected: int, actual: int) -> bool: return self.results[actual][expected] is not NotChecked From b6a6fdcac58b1c4db04c643a633d3b3b67dbbf47 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 7 Apr 2026 08:45:57 +0200 Subject: [PATCH 3/7] fix error: Redundant cast to "str" --- testing/code/test_excinfo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 70499fec893..9998ad1b141 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -768,7 +768,7 @@ def func1(m): reprfuncargs = p.repr_args(entry) assert reprfuncargs is not None assert reprfuncargs.args[0] == ("m", repr("m" * 500)) - assert "..." not in cast(str, reprfuncargs.args[0][1]) + assert "..." not in reprfuncargs.args[0][1] def test_repr_tracebackentry_lines(self, importasmod) -> None: mod = importasmod( From f6223672d06e9e667f24a1677824c91641258457 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 7 Apr 2026 08:50:17 +0200 Subject: [PATCH 4/7] fix and questions --- testing/code/test_code.py | 4 ++-- testing/test_capture.py | 2 +- testing/test_collection.py | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/testing/code/test_code.py b/testing/code/test_code.py index ae5e0e949cf..63f6031e396 100644 --- a/testing/code/test_code.py +++ b/testing/code/test_code.py @@ -148,7 +148,7 @@ class TestExceptionInfo: def test_bad_getsource(self) -> None: try: if False: - pass + pass # type: ignore[unreachable] else: assert False except AssertionError: @@ -164,7 +164,7 @@ class TestTracebackEntry: def test_getsource(self) -> None: try: if False: - pass + pass # type: ignore[unreachable] else: assert False except AssertionError: diff --git a/testing/test_capture.py b/testing/test_capture.py index 11fd18f08ff..86335add299 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -920,7 +920,7 @@ def test_dontreadfrominput() -> None: f = DontReadFromInput() assert f.buffer is f # type: ignore[comparison-overlap] - assert not f.isatty() + assert not f.isatty() # testing/test_capture.py:923: error: Statement is unreachable [unreachable] ?! pytest.raises(OSError, f.read) pytest.raises(OSError, f.readlines) iter_f = iter(f) diff --git a/testing/test_collection.py b/testing/test_collection.py index f83bfd9a712..8f7baad65ea 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -83,6 +83,7 @@ def test_foo(self): fn = pytester.collect_by_name(cls, "test_foo") assert isinstance(fn, pytest.Function) + assert modcol is not None assert fn.getparent(pytest.Module) is modcol assert modcol.module is not None assert modcol.cls is None From ae89b6841e3ebfc0bb4563255b71b8e94b6af887 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Apr 2026 06:50:39 +0000 Subject: [PATCH 5/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- testing/test_capture.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/testing/test_capture.py b/testing/test_capture.py index 86335add299..fc5243ada9f 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -920,7 +920,9 @@ def test_dontreadfrominput() -> None: f = DontReadFromInput() assert f.buffer is f # type: ignore[comparison-overlap] - assert not f.isatty() # testing/test_capture.py:923: error: Statement is unreachable [unreachable] ?! + assert ( + not f.isatty() + ) # testing/test_capture.py:923: error: Statement is unreachable [unreachable] ?! pytest.raises(OSError, f.read) pytest.raises(OSError, f.readlines) iter_f = iter(f) From 501f4f4d341b1f0804e0dbfd71648d4e47f2dfc6 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 7 Apr 2026 09:03:19 +0200 Subject: [PATCH 6/7] order --- testing/test_collection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/test_collection.py b/testing/test_collection.py index 8f7baad65ea..093162ddec4 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -83,8 +83,8 @@ def test_foo(self): fn = pytester.collect_by_name(cls, "test_foo") assert isinstance(fn, pytest.Function) - assert modcol is not None assert fn.getparent(pytest.Module) is modcol + assert modcol is not None assert modcol.module is not None assert modcol.cls is None assert modcol.instance is None From 25c9eb62343579fc98d8b2c13f6bdda954bb742b Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Tue, 7 Apr 2026 17:49:38 +0300 Subject: [PATCH 7/7] Just ignore the unreachable --- testing/test_capture.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/testing/test_capture.py b/testing/test_capture.py index fc5243ada9f..88368fadaae 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -920,9 +920,7 @@ def test_dontreadfrominput() -> None: f = DontReadFromInput() assert f.buffer is f # type: ignore[comparison-overlap] - assert ( - not f.isatty() - ) # testing/test_capture.py:923: error: Statement is unreachable [unreachable] ?! + assert not f.isatty() # type: ignore[unreachable] pytest.raises(OSError, f.read) pytest.raises(OSError, f.readlines) iter_f = iter(f)