Broken reachability checks in match-case #13989
Labels
bug
mypy got something wrong
topic-match-statement
Python 3.10's match statement
topic-reachability
Detecting unreachable code
topic-type-narrowing
Conditional type narrowing / binder
Bug Report
I have two small similar examples for you:
1:
2:
Expected Behavior
Missing return statement
error, because code aftermatch
statement is unreachable.Missing return statement
error and errorstatement is unreachable
on linecase _:
Actual Behavior
Missing return statement
.Missing return statement
. Nostatement is unreachable
error on linecase _:
Error
Missing return statement
will disappear if i removeif True:
condition (in both cases).Error
statement is unreachable
will appear if i replacecase _, _:
withcase _:
. Removing condition doesnt help.Your Environment
mypy.ini
: noAnd now for something a bit different
Mypy cannot narrow types of tuple elements.
The text was updated successfully, but these errors were encountered: