Skip to content

Commit

Permalink
Use oldest supported Python in mypy pre-commit checks (pytest-dev#12747)
Browse files Browse the repository at this point in the history
Follow up to pytest-dev#12744, this ensures type checking works at the oldest Python version supported by pytest.
  • Loading branch information
nicoddemus authored Aug 29, 2024
1 parent c947145 commit 419bc7a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ repos:
- id: mypy
files: ^(src/|testing/|scripts/)
args: []
language_version: "3.8"
additional_dependencies:
- iniconfig>=1.1.0
- attrs>=19.2.0
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@


if TYPE_CHECKING:
from typing import Self
from typing_extensions import Self

from _pytest.fixtures import FixtureManager

Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def pytest_runtest_call(item: Item) -> None:
del sys.last_value
del sys.last_traceback
if sys.version_info >= (3, 12, 0):
del sys.last_exc
del sys.last_exc # type:ignore[attr-defined]
except AttributeError:
pass
try:
Expand All @@ -177,7 +177,7 @@ def pytest_runtest_call(item: Item) -> None:
sys.last_type = type(e)
sys.last_value = e
if sys.version_info >= (3, 12, 0):
sys.last_exc = e
sys.last_exc = e # type:ignore[attr-defined]
assert e.__traceback__ is not None
# Skip *this* frame
sys.last_traceback = e.__traceback__.tb_next
Expand Down
2 changes: 1 addition & 1 deletion testing/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ def runtest(self):
assert sys.last_type is IndexError
assert isinstance(sys.last_value, IndexError)
if sys.version_info >= (3, 12, 0):
assert isinstance(sys.last_exc, IndexError)
assert isinstance(sys.last_exc, IndexError) # type:ignore[attr-defined]

assert sys.last_value.args[0] == "TEST"
assert sys.last_traceback
Expand Down

0 comments on commit 419bc7a

Please sign in to comment.