-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
Description
Bug Report
Given an enum with a value named value assigned with enum.auto() incorrectly gives an assignment error.
To Reproduce
See https://mypy-play.net/?mypy=latest&python=3.10&gist=febab64ba10c1ebc532d7b6038194791
import enum
class A(enum.Enum):
value = enum.auto()Expected Behavior
No error.
Actual Behavior
main.py:3: error: Incompatible types in assignment (expression has type "auto", base class "Enum" defined the type as "int") [assignment]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used:
mypy 1.18.2 (compiled: yes) - Mypy command-line flags:
mypy main.py - Mypy configuration options from
mypy.ini(and other config files): nothing - Python version used: 3.10.18
Additional information
The value must be called value, if it's anything else, no error. E.g., this works:
class A(enum.Enum):
v = enum.auto()Multiple values also works:
class A(enum.Enum):
value = enum.auto()
v = enum.auto()