-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
Right now this code passes type checking:
from enum import Enum
class E(Enum):
_order_ = 'X Y Z' # Should be 'X Y'
X = 1
Y = 2
But, in runtime it fails:
» python out/ex.py
Traceback (most recent call last):
File "/Users/sobolev/Desktop/mypy/out/ex.py", line 3, in <module>
class E(Enum):
File "/Users/sobolev/.pyenv/versions/3.10.0/lib/python3.10/enum.py", line 348, in __new__
raise TypeError('member order does not match _order_')
TypeError: member order does not match _order_
We need to check that _order_
field is valid.
This can be a great addition to my "better Enums" series of PRs.