You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pytest renamed _pytest._code.code._TracebackStyle to _pytest._code.code.TracebackStyle in version 8.3.0, which means that the mypy checks in pipelines here now fail with:
pytest_mypy_plugins/item.py:22: error: Module "_pytest._code.code" has no attribute "_TracebackStyle"; maybe "TracebackStyle", "TracebackType", or "TracebackEntry"? [attr-defined]
You can't work around this renaming in static type checks (there is no recognised syntax for a type checker to change an import statically), so the only work-around is to not import that name until pytest 8.3.0 is the minimum requirement for this project.
I'd instead just define it locally:
if TYPE_CHECKING:
# pytest 8.3.0 renamed _TracebackStyle to TracebackStyle, but there is no syntax
# to assert what version you have using static conditions, so it has to be
# manually re-defined here. Once minimum supported pytest version is >= 8.3.0,
# the following can be replaced with `from _pytest._code.code import TracebackStyle`
TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"]
(I renamed _TracebackStyle to TracebackStyle to make it easier to switch later).
The text was updated successfully, but these errors were encountered:
Pytest renamed
_pytest._code.code._TracebackStyle
to_pytest._code.code.TracebackStyle
in version 8.3.0, which means that the mypy checks in pipelines here now fail with:You can't work around this renaming in static type checks (there is no recognised syntax for a type checker to change an import statically), so the only work-around is to not import that name until pytest 8.3.0 is the minimum requirement for this project.
I'd instead just define it locally:
(I renamed
_TracebackStyle
toTracebackStyle
to make it easier to switch later).The text was updated successfully, but these errors were encountered: