-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Enum members are Enum themselves. Yet mypy sometimes gets confused.
For example:
from enum import Enum
class Spam(Enum):
FOO = "Foo"
m = Spam.FOO
print(m.FOO.FOO) # Valid python. mypy error: "str" has no attribute "FOO"
print(m == m.FOO) # Valid python. mypy error: Non-overlapping equality check
print(m.FOO.startswith("Foo")) # Invalid python. mypy does not complain.
The first two print calls are valid python code. mypy thinks that m.FOO is str. (mypy only shows an error on the second print if --strict-equality is specified.)
The last print raises an AttributeError. mypy does not complain because it things that m.FOO is str.
$ mypy --version
mypy 0.790