-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
Description
Bug Report
The handling of types for IntEnum literals shows no overlap with int literals.
The handling for int variables appears to be correct,
To Reproduce
from enum import IntEnum
class CardVal(IntEnum):
VAL_A = 1
VAL_2 = 2
try:
assert CardVal.VAL_A == 1
except AssertionError:
pass # So we see the second error in mypy
assert CardVal.VAL_2 == 2Expected Behavior
The type of CardVal.VAL_A gets erased to something considered comparable to Literal[1]
Actual Behavior
From the playground link, using python 3.10 / mypy 1.6.1:
main.py:9: error: Non-overlapping equality check (left operand type: "Literal[CardVal.VAL_A]", right operand type: "Literal[1]") [comparison-overlap]
main.py:13: error: Non-overlapping equality check (left operand type: "Literal[CardVal.VAL_2]", right operand type: "Literal[2]") [comparison-overlap]
Found 2 errors in 1 file (checked 1 source file)
The same behaviour has been seen locally with python 3.11 / mypy 1.6.1
sk-