You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type of an Enum nonmember is wrong when accessed through a member #19418
If you add a class variable to an enum using enum.nonmember and then access that variable through a member instead of the class, the type is nonmember[T] instead of just T. Accessing the variable through the class produces the expected result.
fromenumimportEnum, auto, nonmemberclassFoo(Enum):
BAR=auto()
baz=nonmember("A")
deffun(x: str) ->None:
raiseNotImplementedErrorfun(Foo.baz) # No error, works as expectedfun(Foo.BAR.baz) # error: Argument 1 to "fun" has incompatible type "nonmember[str]"; expected "str" [arg-type]
Expected Behavior
Mypy should think that the type of Foo.BAR.baz is str (or even better, Literal["A"])
Actual Behavior
Mypy thinks that the type of Foo.BAR.baz is nonmember[str]
Your Environment
Mypy version used: 1.16.1
Mypy command-line flags: None
Mypy configuration options from mypy.ini (and other config files): None
Activity
Merge branch 'master' into bugfix/pythongh-19418-enum-nonmember-on-in…
Support attribute access on enum members correctly (python#19422)