-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed as not planned
Labels
Description
Bug Report
Mypy does not warn when using non existing attribute on an enum class.
To Reproduce
from enum import Enum
class Test(Enum):
TEST1 = "test1"
TEST2 = "test2"
print(Test.TEST1.value)
print(Test.value)https://mypy-play.net/?mypy=latest&python=3.11&gist=8e46b4e017e3f98bb9c4a2f31525eb8c
Expected Behavior
I expect mypy to warn me that Test has no attribute value:
error: "Type[Test]" has no attribute "value" [attr-defined]
Found 1 error in 1 file (checked 1 source file)
Actual Behavior
Mypy see nothing wrong.
Success: no issues found in 1 source file
I suspect that because the EnumType class implements __getattr__ mypy supposes any attribute can exist 🫤
Your Environment
- Mypy version used: latest
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini(and other config files): - Python version used: 3.11
Yoan-MA and martin1keogh