Exhaustiveness of type tuple[bool, bool]
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
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.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 68/100