-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
The code below fails to type check, but should succeed because it's exhaustive.
There are some possibly related issues, but I don't know if they are all the same bug, the other tickets tend to depend on Union
which this does not: #16650 #15426 #12364
To Reproduce
Playground link: https://mypy-play.net/?mypy=latest&python=3.12&gist=0d21d288fce8aa13d3cc60f4e418960a
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from enum import Enum
from typing import assert_never
class A(Enum):
A0 = 0
A1 = 1
class B(Enum):
B0 = 0
B1 = 1
def test(a: A, b: B) -> bool:
match (a, b):
case (A.A0, B.B0):
return True
case (A.A0, B.B1):
return True
case (A.A1, B.B0):
return True
case (A.A1, B.B1):
return True
case _ as never:
assert_never(never)
return False
Actual Behavior
typecheck_test.py:26: error: Argument 1 to "assert_never" has incompatible type "tuple[A, B]"; expected "NoReturn" [arg-type]
Your Environment
- Mypy version used: 1.8.0
- Mypy command-line flags: n/a
- Mypy configuration options from
mypy.ini
(and other config files): n/a - Python version used: 3.11 (but also happens with 3.12 in playground link)
racinmat, Feuermurmel, PeterJCLaw-mns and wyattscarpenter
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong