-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-metaclassestopic-type-aliasTypeAlias and other type alias issuesTypeAlias and other type alias issues
Description
Bug Report
When a class:
- is defined inside a function, and
- uses a metaclass
then it mypy will inconsistently give an Invalid metaclass
error based on whether the metaclass is specified via an alias name, or the original name from when the class is defined. This behaviour occurs regardless of whether the metaclass is defined inside or outside of the function. I would have expected no error.
To Reproduce
class M(type):
pass
def f() -> None:
_M = M
class C(metaclass=_M): # Error
pass
class D(metaclass=M): # OK
pass
Actual Behavior
main.py:8: error: Invalid metaclass "_M" [misc]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.1.1
- Python version used: 3.11
n1ngu and vodkar
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-metaclassestopic-type-aliasTypeAlias and other type alias issuesTypeAlias and other type alias issues