Runs forever at 100% CPU for generic protocol with bounded TypeVar argument
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Bug Report
This makes mypy run forever at 100% CPU.
Note that numpy must be installed, else mypy returns immediately (I guess it thinks np.float64 = Any).
I cannot reproduce if I remove any of the methods or replace np.float64 with float or str.
To Reproduce
from __future__ import annotations
from typing import Protocol, TypeVar
import numpy as np
I = TypeVar("I")
float_bound = TypeVar('float_bound', bound=float)
float_bound_2 = TypeVar('float_bound_2', bound=float)
class Container(Protocol[I]):
def __abs__(self: Container[float_bound]) -> Container[float_bound]:
...
def __rmul__(self: Container[float_bound], other: np.float64 | Container[float_bound_2], /) -> Container[float_bound | float_bound_2]:
...
def __rtruediv__(self: Container[float_bound], other: np.float64 | Container[float_bound_2], /) -> Container[float_bound | float_bound_2]:
...
def __sub__(self: Container[float_bound], other, /) -> Container[float_bound]:
...
def __truediv__(self: Container[float_bound], other: np.float64 | Container[float_bound_2], /) -> Container[float_bound | float_bound_2]:
...
Actual Behavior
mypy prints no output, it runs forever at 100% CPU (PC fans constantly spinning).
Your Environment
Debian 13, with python3-numpy 1:2.2.4+ds-1
- Mypy version used: both 1.15 from the Debian 13 repo and 1.19.1 from the Debian sid repo. I'm told this happens since mypy 1.9 or older, but I do not have the VM to confirm personally.
- Mypy command-line flags:
--ignore-missing-imports --check-untyped-defs --no-error-summary --no-implicit-reexport --pretty --strict-equality - Mypy configuration options from
mypy.ini(and other config files): these files do not exist - Python version used: 3.13.5. I'm told this happened on older Python versions, but I do not have the VM to confirm personally.
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.
Línea de trabajo
El informe no identifica ningún archivo fuente ni ruta de prueba. Empieza con la reproducción de Protocol/TypeVar proporcionada, con numpy instalado y las opciones de mypy indicadas; después, sigue la ruta de comprobación que no termina. El trabajo estará terminado cuando mypy complete esta entrada sin un uso sostenido de la CPU al 100% y la regresión esté cubierta por una prueba.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- numpy, python
- Área
- devtools, tooling
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100