Skip to content

Exhaustiveness checks for patten matching #2569

Closed
@hcarty

Description

@hcarty

Is your feature request related to a problem? Please describe.

I would like to be able to be able to enable an error when a match does not cover all cases.

Describe the solution you'd like

I would like an option to generate an error when a match statement is not exhaustive. For example, this match statement would error with such an option enabled because the int case is not handled.

IntOrStr = int | str

def handle(x : IntOrStr) -> None:
    match x:
        case str(s):
            print(f"Handled {s}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions