You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test-data/unit/check-python310.test
+11-7Lines changed: 11 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -2689,15 +2689,16 @@ match b:
2689
2689
# flags: --enable-error-code exhaustive-match
2690
2690
2691
2691
a: int = 5
2692
-
match a: # E: Cases within match statement do not exhaustively handle all values: "int". If not intended to handle all cases, use `case _: pass`
2692
+
match a: # E: Match statement has unhandled case for values of type "int" \
2693
+
# N: If match statement is intended to be non-exhaustive, add `case _: pass`
2693
2694
case 1:
2694
2695
pass
2695
2696
2696
2697
b: str = "hello"
2697
-
match b: # E: Cases within match statement do not exhaustively handle all values: "str". If not intended to handle all cases, use `case _: pass`
2698
+
match b: # E: Match statement has unhandled case for values of type "str" \
2699
+
# N: If match statement is intended to be non-exhaustive, add `case _: pass`
2698
2700
case "bye":
2699
2701
pass
2700
-
2701
2702
[case testNonExhaustiveMatchEnumWithFlag]
2702
2703
# flags: --enable-error-code exhaustive-match
2703
2704
@@ -2710,7 +2711,8 @@ class Color(enum.Enum):
2710
2711
2711
2712
val: Color = Color.RED
2712
2713
2713
-
match val: # E: Cases within match statement do not exhaustively handle all values: "Literal[Color.GREEN]". If not intended to handle all cases, use `case _: pass`
2714
+
match val: # E: Match statement has unhandled case for values of type "Literal[Color.GREEN]" \
2715
+
# N: If match statement is intended to be non-exhaustive, add `case _: pass`
2714
2716
case Color.RED:
2715
2717
a = "red"
2716
2718
case Color.BLUE:
@@ -2747,7 +2749,8 @@ class Color(enum.Enum):
2747
2749
2748
2750
val: Color = Color.RED
2749
2751
2750
-
match val: # E: Cases within match statement do not exhaustively handle all values: "Literal[Color.BLUE, Color.GREEN]". If not intended to handle all cases, use `case _: pass`
2752
+
match val: # E: Match statement has unhandled case for values of type "Literal[Color.BLUE, Color.GREEN]" \
2753
+
# N: If match statement is intended to be non-exhaustive, add `case _: pass`
2751
2754
case Color.RED:
2752
2755
a = "red"
2753
2756
[builtins fixtures/enum.pyi]
@@ -2786,8 +2789,9 @@ class B(TypedDict):
2786
2789
num: int
2787
2790
2788
2791
d: A | B
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` \
2790
-
# E: Cases within match statement do not exhaustively handle all values: "B". If not intended to handle all cases, use `case _: pass`
2792
+
match d["tag"]: # E: Match statement has unhandled case for values of type "Literal['b']" \
2793
+
# N: If match statement is intended to be non-exhaustive, add `case _: pass` \
2794
+
# E: Match statement has unhandled case for values of type "B"
2791
2795
case "a":
2792
2796
reveal_type(d) # N: Revealed type is "TypedDict('__main__.A', {'tag': Literal['a'], 'name': builtins.str})"
2793
2797
reveal_type(d["name"]) # N: Revealed type is "builtins.str"
0 commit comments