Regression in 2.4.0: empty constraint tuple in PEP 695 type parameter (`class C[T: ()]`) is no longer reported
I maintainer di solito rispondono entro 1 giorno
@CheerathAniketh ci sta già lavorando.
Dal 11/10/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- backend, testing-qa
Direzione di ricerca
Inizia con il test di conformità generics_syntax_declarations.py alla riga 60, che si aspetta già un errore per class ClassK[T: ()]. Confronta il risultato con mypy 2.3.0 e 2.4.0, quindi esamina la gestione dei vincoli vuoti per i parametri di tipo PEP 695. Il lavoro è terminato quando il test segnala l’errore previsto “at least two constrained types” in 2.4.0.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Report
mypy 2.4.0 no longer reports an error for a PEP 695 type parameter whose constraint tuple is empty (class C[T: ()]). mypy 2.1.0, 2.2.0 and 2.3.0 all report Type variable must have at least two constrained types [misc] on that line. The one-element case T: (str,) and the legacy TypeVar("T", str) are still reported in 2.4.0, so only the empty-tuple path regressed.
To Reproduce
class ClassK[T: ()]: # expected: error: Type variable must have at least two constrained types [misc]
...
class ClassL[T: (str,)]: # still reported in 2.4.0
...
$ mypy --python-version 3.12 repro.py
Expected Behavior
An error on the ClassK line, as in mypy ≤ 2.3.0. CPython itself rejects the declaration at runtime (TypeError: A single constraint is not allowed / empty constraints), and pyright 1.1.414, pyrefly 1.3.2, ty 0.0.86 and zuban 0.10.0 all report it.
Actual Behavior
mypy 2.4.0:
repro.py:4: error: Type variable must have at least two constrained types [misc]
Found 1 error in 1 file (checked 1 source file)
(only ClassL; ClassK on line 1 is silently accepted)
mypy 2.3.0:
repro.py:1: error: Type variable must have at least two constrained types [misc]
repro.py:4: error: Type variable must have at least two constrained types [misc]
Found 2 errors in 1 file (checked 1 source file)
This also flips the typing conformance test generics_syntax_declarations.py (line 60, class ClassK[T: ()]: # E) from automated Pass (mypy 2.1.0, as in the published results) to Fail with 2.4.0.
Your Environment
- Mypy version used: 2.4.0 (compiled: yes); compared against 2.1.0 / 2.2.0 / 2.3.0 in separate venvs
- Mypy command-line flags:
--python-version 3.12(also reproduces with no flags) - Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.12.15, macOS arm64
- Lingua principale
- Python
- Stelle
- 20.7k
- Fork
- 3.3k
- Merge medio
- 1g 20h
- PR unite (30g)
- 102
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi 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.
Altre issue di python/mypy
-
T-string below Python 3.14 also reports import-not-found for string.templatelib on line 1Forse già presa @jw9829 l’ha presa 1 giorno fa. Apertabug topic-parser
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
python/mypy#22184 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
`stubgen --inspect-mode` crashes with `AttributeError on PEP 604 union syntax (X | Y)` *(mypy 2.1.0)*Forse già presa @ayushdoesdev l’ha presa 70 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Inconsistent description of `strict_optional`Forse già presa @Joosboy l’ha presa 86 giorni fa. Apertadocumentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python/mypy#21658 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Cannot set `output` in `mypy.ini`Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug topic-configuration topic-error-reporting
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
python/mypy#21376 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
fix(accounts): Balance Sheet and Profit and Loss crash on PostgreSQL due to MySQL force_indexAperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Discord webhook notifications fail with HTTP 403 (Cloudflare blocks default urllib User-Agent)Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
tharje/spooler-v2#20 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Bump version of azure-servicebusForse già presa @joostlek l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
home-assistant/core#186275 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100