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/) 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 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/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( diff --git a/testing/test_capture.py b/testing/test_capture.py index 11fd18f08ff..88368fadaae 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() # type: ignore[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..093162ddec4 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -84,6 +84,7 @@ def test_foo(self): assert isinstance(fn, pytest.Function) 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