Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stubgen generates reference to types.TracebackType without importing types #17037

Open
henribru opened this issue Mar 16, 2024 · 0 comments
Open
Labels
bug mypy got something wrong topic-stubgen

Comments

@henribru
Copy link
Contributor

henribru commented Mar 16, 2024

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
@henribru henribru added the bug mypy got something wrong label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-stubgen
Projects
None yet
Development

No branches or pull requests

2 participants