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

Class attributes __qualname__ and __module__ should be accessible within class body #10570

Closed
erictraut opened this issue Jun 1, 2021 · 3 comments · Fixed by #16215
Closed
Labels
bug mypy got something wrong topic-runtime-semantics mypy doesn't model runtime semantics correctly

Comments

@erictraut
Copy link

erictraut commented Jun 1, 2021

The attributes __qualname__ and __module__ appear to be accessible from within a class body. These accesses don't generate a runtime error, but mypy reports a "not defined" error.

class Foo:
    print(__doc__)
    print(__name__)
    print(__qualname__)  # error: Name '__qualname__' is not defined
    print(__module__)  # error: Name '__module__' is not defined

This is related to the following bug filed against pyright: microsoft/pylance-release#1376.

@erictraut erictraut added the bug mypy got something wrong label Jun 1, 2021
@supreetsingh10
Copy link

I would like to work on this one, where should I start out with this problem?

@jli
Copy link

jli commented Mar 16, 2022

I think the title of this should be this, right?

Class attributes __qualname__ and __module__ should be accessible within class body

@erictraut erictraut changed the title Class attributes __qualname__ and __name__ should be accessible within class body Class attributes __qualname__ and __module__ should be accessible within class body Mar 16, 2022
@erictraut
Copy link
Author

@jli, yes, good catch. I've updated the issue name.

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-runtime-semantics mypy doesn't model runtime semantics correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants