Errors for incorrect type on `**kwargs` should give the name of the 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
In case of **kwargs being passed to an overloaded function, one issue gets raised for every overload of that function. This problem is not present when passing a regular incompatible type to that overloaded function, eg. int
To Reproduce
import json
from typing import Any
def load(data: str, **kwargs: object) -> Any:
return json.loads(data, **kwargs)
Gist: https://mypy-play.net/?mypy=master&python=3.11&gist=8d7f8bb50c5f9022469b59ec127df614
The bug won't reproduce for eg. if **kwargs: object was replaced with x: object.
Expected Behavior
Single issue being raised.
Actual Behavior
$ mypy asd.py
asd.py:5: error: Argument 2 to "loads" has incompatible type "**dict[str, object]"; expected "type[JSONDecoder] | None" [arg-type]
asd.py:5: error: Argument 2 to "loads" has incompatible type "**dict[str, object]"; expected "Callable[[dict[Any, Any]], Any] | None" [arg-type]
asd.py:5: error: Argument 2 to "loads" has incompatible type "**dict[str, object]"; expected "Callable[[str], Any] | None" [arg-type]
asd.py:5: error: Argument 2 to "loads" has incompatible type "**dict[str, object]"; expected "Callable[[list[tuple[Any, Any]]], Any] | None" [arg-type]
Found 4 errors in 1 file (checked 1 source file)
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 ejecutando el reproductor de mypy-play proporcionado o el comando mostrado mypy asd.py; después, sigue cómo las llamadas sobrecargadas gestionan los diagnósticos de **kwargs. Se considera completado cuando el ejemplo informa de un error de argumento incompatible en lugar de un error por cada sobrecarga, con una prueba de regresión que cubra este comportamiento.
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
- 38/100