Skip to content

Commit 4f2e9b4

Browse files
committed
fix: do not narrow if UninhabitedType in union
1 parent a017ea5 commit 4f2e9b4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mypy/checker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5304,6 +5304,10 @@ def visit_match_stmt(self, s: MatchStmt) -> None:
53045304
new_type_context = get_proper_type(pattern_type.rest_type)
53055305
if isinstance(new_type_context, UninhabitedType):
53065306
continue
5307+
if isinstance(new_type_context, UnionType) and any(
5308+
isinstance(get_proper_type(t), UninhabitedType) for t in new_type_context.items
5309+
):
5310+
continue
53075311
type_context = new_type_context
53085312

53095313
type_maps: list[TypeMap] = [t.captures for t in pattern_types]

0 commit comments

Comments
 (0)