Skip to content

Commit be9e36e

Browse files
Use oldest supported Python in mypy pre-commit checks (#12747) (#12750)
Follow up to #12744, this ensures type checking works at the oldest Python version supported by pytest. (cherry picked from commit 419bc7a) Co-authored-by: Bruno Oliveira <[email protected]>
1 parent e22c188 commit be9e36e

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ repos:
2626
- id: mypy
2727
files: ^(src/|testing/|scripts/)
2828
args: []
29+
language_version: "3.8"
2930
additional_dependencies:
3031
- iniconfig>=1.1.0
3132
- attrs>=19.2.0

src/_pytest/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050

5151
if TYPE_CHECKING:
52-
from typing import Self
52+
from typing_extensions import Self
5353

5454
from _pytest.fixtures import FixtureManager
5555

src/_pytest/runner.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def pytest_runtest_call(item: Item) -> None:
167167
del sys.last_value
168168
del sys.last_traceback
169169
if sys.version_info >= (3, 12, 0):
170-
del sys.last_exc
170+
del sys.last_exc # type:ignore[attr-defined]
171171
except AttributeError:
172172
pass
173173
try:
@@ -177,7 +177,7 @@ def pytest_runtest_call(item: Item) -> None:
177177
sys.last_type = type(e)
178178
sys.last_value = e
179179
if sys.version_info >= (3, 12, 0):
180-
sys.last_exc = e
180+
sys.last_exc = e # type:ignore[attr-defined]
181181
assert e.__traceback__ is not None
182182
# Skip *this* frame
183183
sys.last_traceback = e.__traceback__.tb_next

testing/test_runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ def runtest(self):
10301030
assert sys.last_type is IndexError
10311031
assert isinstance(sys.last_value, IndexError)
10321032
if sys.version_info >= (3, 12, 0):
1033-
assert isinstance(sys.last_exc, IndexError)
1033+
assert isinstance(sys.last_exc, IndexError) # type:ignore[attr-defined]
10341034

10351035
assert sys.last_value.args[0] == "TEST"
10361036
assert sys.last_traceback

0 commit comments

Comments
 (0)