I have this example:
fromenumimportEnumclassA(Enum):
x=1x=2reveal_type(A.x)
Mypy is happy with it:
» mypyex.pyex.py:8: note: Revealedtypeis"Literal[ex.A.x]?"
But, it raises in runtime:
» pythonex.pyTraceback (mostrecentcalllast):
File"/Users/sobolev/Desktop/mypy/ex.py", line4, in<module>classA(Enum):
File"/Users/sobolev/Desktop/mypy/ex.py", line6, inAx=2File"/Users/sobolev/.pyenv/versions/3.9.1/lib/python3.9/enum.py", line99, in__setitem__raiseTypeError('Attempted to reuse key: %r'%key)
TypeError: Attemptedtoreusekey: 'x'This is a part of my "better enum" series:
I have this example:
Mypy is happy with it:
But, it raises in runtime:
This is a part of my "better enum" series:
Enumplugin should supportuniquecheck where possible #10858