- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 3k
 
Open
Labels
Description
Bug Report
If you compare an enum to a literal, then the type becomes that literal. Somewhat a followup to #19594.
To Reproduce
from enum import Enum
class A(str, Enum):
    a = "b"
    b = "a"
def test(a: A) -> None:
    if a == "b":
        reveal_type(a)Expected Behavior
main.py:9: note: Revealed type is "Literal[A.a]"
Success: no issues found in 1 source file
Actual Behavior
main.py:9: note: Revealed type is "Literal['b']"
Success: no issues found in 1 source file
Your Environment
Reproduced in mypy playground.
- Mypy version used: 1.17.1
 - Mypy command-line flags: N/A
 - Mypy configuration options from 
mypy.ini(and other config files): N/A - Python version used: 3.12
 
sterliakov