|
17 | 17 |
|
18 | 18 | import _pytest._code |
19 | 19 | from _pytest._code import getfslineno |
20 | | -from _pytest._code.code import ExceptionChainRepr |
21 | 20 | from _pytest._code.code import ExceptionInfo |
22 | | -from _pytest._code.code import ReprExceptionInfo |
| 21 | +from _pytest._code.code import TerminalRepr |
23 | 22 | from _pytest.compat import cached_property |
24 | 23 | from _pytest.compat import overload |
25 | 24 | from _pytest.compat import TYPE_CHECKING |
|
29 | 28 | from _pytest.deprecated import NODE_USE_FROM_PARENT |
30 | 29 | from _pytest.fixtures import FixtureDef |
31 | 30 | from _pytest.fixtures import FixtureLookupError |
32 | | -from _pytest.fixtures import FixtureLookupErrorRepr |
33 | 31 | from _pytest.mark.structures import Mark |
34 | 32 | from _pytest.mark.structures import MarkDecorator |
35 | 33 | from _pytest.mark.structures import NodeKeywords |
|
43 | 41 | # Imported here due to circular import. |
44 | 42 | from _pytest.main import Session |
45 | 43 | from _pytest.warning_types import PytestWarning |
| 44 | + from _pytest._code.code import _TracebackStyle |
46 | 45 |
|
47 | 46 |
|
48 | 47 | SEP = "/" |
@@ -355,8 +354,10 @@ def _prunetraceback(self, excinfo): |
355 | 354 | pass |
356 | 355 |
|
357 | 356 | def _repr_failure_py( |
358 | | - self, excinfo: ExceptionInfo[BaseException], style=None, |
359 | | - ) -> Union[str, ReprExceptionInfo, ExceptionChainRepr, FixtureLookupErrorRepr]: |
| 357 | + self, |
| 358 | + excinfo: ExceptionInfo[BaseException], |
| 359 | + style: "Optional[_TracebackStyle]" = None, |
| 360 | + ) -> TerminalRepr: |
360 | 361 | if isinstance(excinfo.value, ConftestImportFailure): |
361 | 362 | excinfo = ExceptionInfo(excinfo.value.excinfo) |
362 | 363 | if isinstance(excinfo.value, fail.Exception): |
@@ -406,8 +407,10 @@ def _repr_failure_py( |
406 | 407 | ) |
407 | 408 |
|
408 | 409 | def repr_failure( |
409 | | - self, excinfo, style=None |
410 | | - ) -> Union[str, ReprExceptionInfo, ExceptionChainRepr, FixtureLookupErrorRepr]: |
| 410 | + self, |
| 411 | + excinfo: ExceptionInfo[BaseException], |
| 412 | + style: "Optional[_TracebackStyle]" = None, |
| 413 | + ) -> Union[str, TerminalRepr]: |
411 | 414 | """ |
412 | 415 | Return a representation of a collection or test failure. |
413 | 416 |
|
@@ -453,13 +456,16 @@ def collect(self) -> Iterable[Union["Item", "Collector"]]: |
453 | 456 | """ |
454 | 457 | raise NotImplementedError("abstract") |
455 | 458 |
|
456 | | - def repr_failure(self, excinfo): |
| 459 | + # TODO: This omits the style= parameter which breaks Liskov Substitution. |
| 460 | + def repr_failure( # type: ignore[override] # noqa: F821 |
| 461 | + self, excinfo: ExceptionInfo[BaseException] |
| 462 | + ) -> Union[str, TerminalRepr]: |
457 | 463 | """ |
458 | 464 | Return a representation of a collection failure. |
459 | 465 |
|
460 | 466 | :param excinfo: Exception information for the failure. |
461 | 467 | """ |
462 | | - if excinfo.errisinstance(self.CollectError) and not self.config.getoption( |
| 468 | + if isinstance(excinfo.value, self.CollectError) and not self.config.getoption( |
463 | 469 | "fulltrace", False |
464 | 470 | ): |
465 | 471 | exc = excinfo.value |
|
0 commit comments