Files
ruff/crates/red_knot_python_semantic/resources/mdtest/narrow/match.md
Micha Reiser 6aaf1d9446 [red-knot] Remove lint-phase (#13922)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-10-25 18:40:52 +00:00

306 B

Narrowing for match statements

Single match pattern

def bool_instance() -> bool:
    return True

flag = bool_instance()

x = None if flag else 1
reveal_type(x)  # revealed: None | Literal[1]

y = 0

match x:
    case None:
        y = x

reveal_type(y)  # revealed: Literal[0] | None