Skip to content

pyrefly doesn't recognize __module__ and __qualname__ in class body #1462

@randolf-scholz

Description

@randolf-scholz

Describe the Bug

During class creation the constants __module__, __qualname__ and in 3.13+ also __firstlineno__ are available:

>>> class Bar:
...     print(vars())
...     
{'__module__': '__main__', '__qualname__': 'Bar', '__firstlineno__': 1}

pyrefly doesn't recognize these:

from typing import reveal_type

class Bar:
    reveal_type(__qualname__)  # E: unknown-name
    reveal_type(__module__)    # E: unknown-name

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN2UYANxiooAfSbEYAHXRyAxlFRw4dAEKpKiOXT0DhoiVJgAKceICOAVzHpUNGBYCUegMR0AoojrX0Aa3RcAHd0AFp7R119QRExSWYzCxpcTGtYF306D29fAKDQiIdZdBAAGhBrBmg4EnJEEA8AVWqoCCY6MD8Fatx0ODk5TBgwTt4aVAZxdGsabBhKU3wfVgZXMIA%2BOjgGbWi9QQZrSnROmRAAOVn57TpgfABfc7lykDJBMChSQgZaKAoPAAFUgfL7bDA4Ah0BR9SBsY6TCB9QhyDwAZRgMDoAAsGAxiHBEAB6InvEZfQi8NhEmDoImYXAKOBEmHoOEI3p0saUOioISoaCobCwaGwiDwyiIvp0XDETm1ORkBjYvphESUOBI04AXjo5wAzIQAIwAJmepQeFVQPQgIgAYtAYBQ0Fg8EQyCAHkA

Metadata

Metadata

Assignees

Labels

UserBugs reported by external users that should be prioritisedtypechecking

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions