Closed
Description
Bug Report
(A clear and concise description of what the bug is.)
To Reproduce
Gist: https://mypy-play.net/?mypy=latest&python=3.12&gist=61f3db46cdaf7782c6679322e8809f47&flags=strict%2Ccheck-untyped-defs
import enum
import random
class Test(enum.Enum):
A = 1
B = 2
val = list(Test)[random.randint(0, 2)]
reveal_type(val)
match val:
case Test.A:
print("A")
# case Test.B:
# print("B")
val2 = random.randint(0, 2)
reveal_type(val2)
match val2:
case 1:
print("1")
Expected Behavior
Expected both of the match statements to raise errors due to not exhaustively matching on the enum/int values
Actual Behavior
File is passed as ok when it should raise errors
Pyright is able to catch both cases in strict mode as expected in case this helps: pyright playground link
Your Environment
- Mypy version used: tested on 1.15.0, 1.14.1, 1.10.1
- Mypy command-line flags:
--strict
- Python version used: 3.12 & 3.10
Possibly Related Issues?
Below are the most relevant issues I could spot, but don't seem to quite align with the case here to the best of my understanding