Skip to content

Exhaustiveness of type tuple[bool, bool] #21968

Description

@JulienPalard

Bug Report

It looks like the exhaustiveness of tuples of bools is not checked in match statements.

To Reproduce

def measure(a: bool, b: bool) -> float:
    match a, b:
        case True, True:
            return 1
        case True, False:
            return 0.9
        case False, True:
            return 0.5
        case False, False:
            return 0

Expected Behavior

Should pass, looks exhaustive to me (or I should go take a nap).

Actual Behavior

$ mypy --enable-error-code exhaustive-match repro.py
repro.py:1: error: Missing return statement  [return]
repro.py:2: error: Match statement has unhandled case for values of type "tuple[bool, bool]"  [exhaustive-match]
repro.py:2: note: If match statement is intended to be non-exhaustive, add `case _: pass`
Found 2 errors in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: mypy 2.3.1 (compiled: yes)
  • Mypy command-line flags: --enable-error-code exhaustive-match
  • Mypy configuration options from mypy.ini (and other config files): ø
  • Python version used: 3.14.7

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions