|
6 | 6 | import sys |
7 | 7 | import tempfile |
8 | 8 | from pathlib import Path |
9 | | -from typing import TYPE_CHECKING, Any, Dict, List, Optional, TextIO, Tuple, Union |
| 9 | +from typing import ( |
| 10 | + TYPE_CHECKING, |
| 11 | + Any, |
| 12 | + Dict, |
| 13 | + List, |
| 14 | + Literal, |
| 15 | + Optional, |
| 16 | + TextIO, |
| 17 | + Tuple, |
| 18 | + Union, |
| 19 | +) |
10 | 20 |
|
11 | 21 | import py |
12 | 22 | import pytest |
|
18 | 28 | from mypy.fscache import FileSystemCache |
19 | 29 | from mypy.main import process_options |
20 | 30 |
|
21 | | -if TYPE_CHECKING: |
22 | | - from _pytest._code.code import _TracebackStyle |
23 | | - |
24 | 31 | from pytest_mypy_plugins import configs, utils |
25 | 32 | from pytest_mypy_plugins.collect import File, YamlTestFile |
26 | 33 | from pytest_mypy_plugins.utils import ( |
|
30 | 37 | fname_to_module, |
31 | 38 | ) |
32 | 39 |
|
| 40 | +if TYPE_CHECKING: |
| 41 | + # pytest 8.3.0 renamed _TracebackStyle to TracebackStyle, but there is no syntax |
| 42 | + # to assert what version you have using static conditions, so it has to be |
| 43 | + # manually re-defined here. Once minimum supported pytest version is >= 8.3.0, |
| 44 | + # the following can be replaced with `from _pytest._code.code import TracebackStyle` |
| 45 | + TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"] |
| 46 | + |
33 | 47 |
|
34 | 48 | class TraceLastReprEntry(ReprEntry): |
35 | 49 | def toterminal(self, tw: TerminalWriter) -> None: |
@@ -443,7 +457,7 @@ def prepare_config_file(self, execution_path: Path) -> Optional[str]: |
443 | 457 | return None |
444 | 458 |
|
445 | 459 | def repr_failure( |
446 | | - self, excinfo: ExceptionInfo[BaseException], style: Optional["_TracebackStyle"] = None |
| 460 | + self, excinfo: ExceptionInfo[BaseException], style: Optional["TracebackStyle"] = None |
447 | 461 | ) -> Union[str, TerminalRepr]: |
448 | 462 | if excinfo.errisinstance(SystemExit): |
449 | 463 | # We assume that before doing exit() (which raises SystemExit) we've printed |
|
0 commit comments