Skip to content

Commit

Permalink
test: add unit test testMatchOrPatternMatchExhaustivenes
Browse files Browse the repository at this point in the history
  • Loading branch information
shenyih0ng committed Nov 10, 2024
1 parent 0857a9f commit ff90fbb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test-data/unit/check-python310.test
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,22 @@ def f(x: int | str) -> int:
case str() as s:
return 1

[case testMatchOrPatternExhaustiveness]
from typing import NoReturn, Literal
def assert_never(x: NoReturn) -> None: ...

Color = Literal["blue", "green", "red"]
c: Color

match c:
case "blue":
reveal_type(c) # N: Revealed type is "Literal['blue']"
case "green" | "notColor":
reveal_type(c) # N: Revealed type is "Literal['green']"
case _:
assert_never(c) # E: Argument 1 to "assert_never" has incompatible type "Literal['red']"; expected "Never"
[typing fixtures/typing-typeddict.pyi]

[case testMatchAsPatternIntersection-skip]
class A: pass
class B: pass
Expand Down

0 comments on commit ff90fbb

Please sign in to comment.