Regression in 2.4.0: empty constraint tuple in PEP 695 type parameter (`class C[T: ()]`) is no longer reported
Los mantenedores suelen responder en 1 día
@CheerathAniketh ya está trabajando en esto.
Desde el 11/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- backend, testing-qa
Línea de trabajo
Empieza con la prueba de conformidad generics_syntax_declarations.py en la línea 60, que ya espera un error para class ClassK[T: ()]. Compara su resultado con mypy 2.3.0 y 2.4.0 y luego sigue el tratamiento de las restricciones vacías para los parámetros de tipo de PEP 695. El trabajo estará terminado cuando la prueba informe del error esperado “at least two constrained types” en 2.4.0.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 20.7k
- Forks
- 3.3k
- Merge medio
- 2 d 1 h
- PR fusionados (30 d)
- 104
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python/mypy
-
T-string below Python 3.14 also reports import-not-found for string.templatelib on line 1Posiblemente ocupada @jw9829 la tomó hace 2 días. Abiertobug topic-parser
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
python/mypy#22184 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
`stubgen --inspect-mode` crashes with `AttributeError on PEP 604 union syntax (X | Y)` *(mypy 2.1.0)*Posiblemente ocupada @ayushdoesdev la tomó hace 71 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Inconsistent description of `strict_optional`Posiblemente ocupada @Joosboy la tomó hace 87 días. Abiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
python/mypy#21658 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Cannot set `output` in `mypy.ini`Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug topic-configuration topic-error-reporting
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
python/mypy#21376 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de python/mypy
Issues similares
-
customer-reported question
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Azure/azure-sdk-for-python#49548 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
btclib-org/btclib-wallet#409 ·
Los mantenedores suelen responder en 1 día
-
Phase 2 PSA Capability & Career Profile
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
fastmachinelearning/hls4ml#1582 ·
Los mantenedores suelen responder en 3 días
-
Sort modelsAbiertoenhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día