Open
Description
Bug Report
When stubgen generates annotations for __exit__
, it references types.TracebackType
without importing types
To Reproduce
Run stubgen on this file:
class Foo:
def __exit__(
self,
type,
value,
traceback,
) -> None: ...
Expected Behavior
import types
class Foo:
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None) -> None: ...
Actual Behavior
class Foo:
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None) -> None: ...
Notice that it uses types.TracebackType
to annotate traceback
, but doesn't add an import for types
.
Your Environment
- Mypy version used: 1.9.0
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini
(and other config files): N/A - Python version used: 3.10.0