Skip to content

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

Closed
@erictraut

Description

@erictraut

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-runtime-semanticsmypy doesn't model runtime semantics correctly

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions