python / python/mypy

`UNBOUND_TYPEVAR` error message should be more direct and shorter

Abierto
#20,922 17 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug
Lenguaje dominante
Python
Estrellas
20.6k
Forks
3.3k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

*Notes:

The last 3 examples get the same indirect and long error messages of UNBOUND_TYPEVAR as shown below:

*Notes:

  • A parameter is a variable defined in a function header to receive an argument.
  • An argument is a value passed to a function parameter.

A function returning TypeVar should receive at least one argument containing the same TypeVar

With T for x:
def func[T](x: T) -> T:
    return x
# No error
Without T for x:
def func[T](x) -> T:
    return x
# error: A function returning TypeVar should receive at least one argument containing the same TypeVar
With no parameters:
from typing import cast

def func[T]() -> T:
    return cast(T, 'Hello')
# error: A function returning TypeVar should receive at least one argument containing the same TypeVar
With T1 for x and T2 for return type:
def func[T1, T2](x: T1) -> T2:
    return x
# error: A function returning TypeVar should receive at least one argument containing the same TypeVar

So, the same indirect and long error messages of UNBOUND_TYPEVAR should be changed:

From:

A function returning TypeVar should receive at least one argument containing the same TypeVar

To more direct and shorter one below:

A function returning TypeVar should have at least one same TypeVar parameter

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con los ejemplos de mypy test.py y localiza dónde se genera y se prueba el diagnóstico UNBOUND_TYPEVAR. Actualiza el mensaje con la redacción más breve solicitada y verifica después que los tres ejemplos que fallan produzcan el nuevo diagnóstico sin cambiar el ejemplo válido.

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
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.