Regression in 2.4.0: empty constraint tuple in PEP 695 type parameter (`class C[T: ()]`) is no longer reported
Maintainer antworten meist innerhalb von 1 Tag
@CheerathAniketh arbeitet bereits daran.
Seit 11.10.2026.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 72/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- python
- Bereich
- backend, testing-qa
Rechercherichtung
Beginne mit dem Conformance-Test generics_syntax_declarations.py in Zeile 60, der bereits einen Fehler für class ClassK[T: ()] erwartet. Vergleiche sein Ergebnis mit mypy 2.3.0 und 2.4.0 und verfolge anschließend die Behandlung leerer Constraints für PEP-695-Typparameter. Fertig ist die Arbeit, wenn der Test in 2.4.0 den erwarteten Fehler „at least two constrained types“ meldet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Python
- Sterne
- 20.7k
- Forks
- 3.3k
- Ø Merge
- 2 T. 1 Std.
- Gemergte PRs (30 T.)
- 104
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python/mypy
-
T-string below Python 3.14 also reports import-not-found for string.templatelib on line 1Evtl. vergeben @jw9829 hat das vor 2 Tagen übernommen. Offenbug topic-parser
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
python/mypy#22184 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
`stubgen --inspect-mode` crashes with `AttributeError on PEP 604 union syntax (X | Y)` *(mypy 2.1.0)*Evtl. vergeben @ayushdoesdev hat das vor 71 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
Inconsistent description of `strict_optional`Evtl. vergeben @Joosboy hat das vor 88 Tagen übernommen. Offendocumentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
python/mypy#21658 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Cannot set `output` in `mypy.ini`Evtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offenbug topic-configuration topic-error-reporting
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
python/mypy#21376 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
WingedGuardian/GENesis-AGI#3375 ·
Maintainer antworten meist innerhalb von 1 Tag
-
curriculum documentation quality
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
githubnext/gh-aw-workshop#4601 ·
Maintainer antworten meist innerhalb von 1 Tag
-
approved Good First Issue scope: docs
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
hiero-ledger/hiero-sdk-python#2730 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag