You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running this code will actually crash with a TypeError, but mypy will pass:
For the IntEnum.INCORRECT_AUTO: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'type'
For the StrEnum.INCORRECT_AUTO: TypeError: <class 'enum.auto'> is not a string
Expected Behavior
I expect mypy to error when one forgets to call auto, as:
The code doesn't run
Even if it did run, the enum's value wouldn't be a primitive as intended
Actual Behavior
mypy passes with the below output:
a.py:7:13: note: Revealed type is "builtins.int"
a.py:8:13: note: Revealed type is "def () -> enum.auto"
a.py:14:13: note: Revealed type is "builtins.str"
a.py:15:13: note: Revealed type is "def () -> enum.auto"
Your Environment
Mypy version used: 1.11.1
Mypy command-line flags: n/a
Mypy configuration options from mypy.ini (and other config files): n/a
Python version used: 3.12.4
The text was updated successfully, but these errors were encountered:
Bug Report
mypy
is not detecting forgetting to callenum.auto()
inIntEnum
andStrEnum
.To Reproduce
Running this code will actually crash with a
TypeError
, butmypy
will pass:IntEnum.INCORRECT_AUTO
:TypeError: int() argument must be a string, a bytes-like object or a real number, not 'type'
StrEnum.INCORRECT_AUTO
:TypeError: <class 'enum.auto'> is not a string
Expected Behavior
I expect
mypy
to error when one forgets to callauto
, as:Actual Behavior
mypy
passes with the below output:Your Environment
mypy.ini
(and other config files): n/aThe text was updated successfully, but these errors were encountered: