Skip to content

Commit ff90fbb

Browse files
committed
test: add unit test testMatchOrPatternMatchExhaustivenes
1 parent 0857a9f commit ff90fbb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test-data/unit/check-python310.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,22 @@ def f(x: int | str) -> int:
17021702
case str() as s:
17031703
return 1
17041704

1705+
[case testMatchOrPatternExhaustiveness]
1706+
from typing import NoReturn, Literal
1707+
def assert_never(x: NoReturn) -> None: ...
1708+
1709+
Color = Literal["blue", "green", "red"]
1710+
c: Color
1711+
1712+
match c:
1713+
case "blue":
1714+
reveal_type(c) # N: Revealed type is "Literal['blue']"
1715+
case "green" | "notColor":
1716+
reveal_type(c) # N: Revealed type is "Literal['green']"
1717+
case _:
1718+
assert_never(c) # E: Argument 1 to "assert_never" has incompatible type "Literal['red']"; expected "Never"
1719+
[typing fixtures/typing-typeddict.pyi]
1720+
17051721
[case testMatchAsPatternIntersection-skip]
17061722
class A: pass
17071723
class B: pass

0 commit comments

Comments
 (0)