Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Exhaustiveness of type tuple[bool, bool]

Aperta
#21,968 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
compilers

Direzione di ricerca

Esegui la riproduzione fornita con Python 3.14.7 e --enable-error-code exhaustive-match, quindi traccia il modo in cui l'analisi exhaustive-match gestisce tuple[bool, bool] nelle istruzioni match. Il lavoro è completato quando i quattro casi booleani vengono riconosciuti come esaustivi senza che venga segnalato un errore missing-return o unhandled-case, mentre i match effettivamente incompleti continuano a segnalare errori.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug topic-match-statement topic-reachability

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
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Merge medio
1g 3h
PR unite (30g)
59

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python/mypy

Tutte le issue di python/mypy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.