Exhaustive checks with assert_never
when using match
on a 2-tuple fails
#16650
Labels
assert_never
when using match
on a 2-tuple fails
#16650
Bug Report
I learned about
assert_never
, with which checks for exhaustiveness can be performed. I wanted to use it in a match statement where I want to cover all 4 possible scenarios of atuple[int|None, int|None]
. Unfortunately, when adding the catch-allcase
arm that containstyping.assert_never
, I get a typing error indicating a non-exhaustive check above.The error persists in a couple of variations. In particular, it persists when using 1-tuple. However, when matching on one value directly, using
assert_never
works as intended.To Reproduce
https://gist.github.com/mypy-play/1df3d1b4c9e82226df17094a9f9c6af5
https://mypy-play.net/?mypy=latest&python=3.12&gist=1df3d1b4c9e82226df17094a9f9c6af5
Expected Behavior
All examples in the provided Gist should pass the type checks.
Actual Behavior
Mypy rejects the first three functions of the Gist. In particular, it's output reads:
Your Environment
Since I am using the Gist, I hope my particular environment doesn't matter much.
The text was updated successfully, but these errors were encountered: