Skip to content

Commit 914bff4

Browse files
committed
fixup! Add test for more complex narrowing use case
Fix for more deterministic behaviour
1 parent d219871 commit 914bff4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

mypy/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5512,7 +5512,7 @@ def visit_match_stmt(self, s: MatchStmt) -> None:
55125512
unmatched_types = else_map
55135513

55145514
if unmatched_types is not None:
5515-
for typ in set(unmatched_types.values()):
5515+
for typ in list(unmatched_types.values()):
55165516
self.msg.match_statement_inexhaustive_match(typ, s)
55175517

55185518
# This is needed due to a quirk in frame_context. Without it types will stay narrowed

test-data/unit/check-python310.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2786,7 +2786,7 @@ class B(TypedDict):
27862786
num: int
27872787

27882788
d: A | B
2789-
match d["tag"]: # E: Cases within match statement do not exhaustively handle all values: "B". If not intended to handle all cases, use `case _: pass` # E: Cases within match statement do not exhaustively handle all values: "Literal['b']". If not intended to handle all cases, use `case _: pass`
2789+
match d["tag"]: # E: Cases within match statement do not exhaustively handle all values: "Literal['b']". If not intended to handle all cases, use `case _: pass` # E: Cases within match statement do not exhaustively handle all values: "B". If not intended to handle all cases, use `case _: pass`
27902790
case "a":
27912791
reveal_type(d) # N: Revealed type is "TypedDict('__main__.A', {'tag': Literal['a'], 'name': builtins.str})"
27922792
reveal_type(d["name"]) # N: Revealed type is "builtins.str"

0 commit comments

Comments
 (0)