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
Bug Report
I stumbled across a weird issue with literals and using the .name property with enums. I was wondering if this is expected behavior. Seems inconsistent to me.
To Reproduce
fromenumimportEnumfromtypingimportLiteralclassFoo(Enum):
A=1B=1keys=Literal["A", "B", "C"]
deff(name: keys) ->None:
print(name)
foo: Foo=Foo.Af(foo.name) # Error: Argument 1 to "f" has incompatible type "str"; expected "Literal['A', 'B', 'C']"f(Foo.A.name) # No Error
Expected Behavior
I would expect both versions to be valid.
Your Environment
Mypy version used: mypy 1.15.0 (compiled: yes)
Mypy command-line flags: none
Mypy configuration options from mypy.ini (and other config files): none
Python version used: 3.11.11
The text was updated successfully, but these errors were encountered:
Bug Report
I stumbled across a weird issue with literals and using the
.name
property with enums. I was wondering if this is expected behavior. Seems inconsistent to me.To Reproduce
Expected Behavior
I would expect both versions to be valid.
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: