Exhaustiveness of type tuple[bool, bool]
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Führe die bereitgestellte Reproduktion mit Python 3.14.7 und --enable-error-code exhaustive-match aus und verfolge anschließend, wie die exhaustive-match-Analyse tuple[bool, bool] in match-Anweisungen behandelt. Als erledigt gilt die Aufgabe, wenn die vier booleschen Fälle als vollständig erkannt werden, ohne dass ein missing-return- oder unhandled-case-Fehler gemeldet wird, während tatsächlich unvollständige Matches weiterhin Fehler melden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 68/100