Bug - Type aliasing typing.Tuple is treated as if the empty Tuple is being aliased
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
This is a bug report.
Type aliasing typing.Tuple is treated as if the empty tuple (typing.Tuple[()]) is being aliased.
Here is some sample code that converts Polar coordinates into Cartesian:
import math
import typing
Tuple = typing.Tuple
def cartesian(r: int, θ: int) -> Tuple[float, float]:
rad = math.radians(θ)
return r*math.cos(rad), r*math.sin(rad)
r = 12
θ = 195
x,y = cartesian(r, θ)
print(f"({r}, {θ}°) = ({x:.2f}, {y:.2f})")
$ python3 example.py
(12, 195°) = (-11.59, -3.11)
$ mypy example.py
example.py:7: error: Bad number of arguments for type alias, expected: 0, given: 2
Found 1 error in 1 file (checked 1 source file)
What is the actual behavior/output?
example.py:7: error: Bad number of arguments for type alias, expected: 0, given: 2
Found 1 error in 1 file (checked 1 source file)
What is the behavior/output you expect?
Success: no issues found in 1 source file
Such as when from typing import Tuple is used instead.
What are the versions of mypy and Python you are using?
I'm using mypy version 0.77 installed using pip and Python 3.7.7 instead via homebrew on macOS Catalina 10.15.4.
Do you see the same issue after installing mypy from Git master?
Yes.
What are the mypy flags you are using? (For example --strict-optional)
None.
Additional details
It might be related to #8273. I know Tuple and Callable are both mentioned in PEP 484 as being different.
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
Comienza con la reproducción en example.py y ejecuta mypy sin flags adicionales, comparando la anotación aliased typing.Tuple con la importación directa descrita en el informe. El trabajo estará terminado cuando la forma aliased pase correctamente la comprobación de tipos y produzca la salida esperada “Success: no issues found”.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- devtools
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100