-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
Bug Report
When comparing a member of StrEnum to a string, it seems that Mypy assumes that the check is always False and does not type-check code under the condition.
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.12&gist=f7c8364d301ada4067a9a6f515b9e161
import typing
import enum
class MyEnum(str, enum.Enum):
A = 'a'
class MyEnum2(enum.StrEnum):
A = 'a'
if MyEnum.A == 'a':
1 + ''
if MyEnum2.A == 'a':
1 + ''
Expected Behavior
Mypy should flag both 1 + ''
expressions as type errors because these conditions evaluate to True
in runtime.
Actual Behavior
Mypy does not report errors
Your Environment
- Mypy version used: 1.9.0
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.12
sk-