Mypy should report why each possible overload doesn't match
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 54
Descripción
Feature
Currently when no overload is valid for a function call mypy just lists the overloads with no explanation for why each one doesn't work:
No overload variant of "target" matches argument types "TargetType", "str", "ClobberConfig" [call-overload]
Possible overload variants:
def target(*, typ: TargetType, path: str | Path) -> Target[NoConfig]
def target(*, target_path: TargetPath) -> Target[NoConfig]
def [ConfigT <: Config] target(*, target_path: TargetPath, config: ConfigT) -> Target[ConfigT]
def [ConfigT <: Config] target(*, typ: TargetType, path: str | Path, config: ConfigT) -> Target[ConfigT]
Pitch
However, in this scenario I've manually verified that the last overload really should work. It's possible that it's a mypy bug, or it's possible that my reasoning is wrong, but if my reasoning is wrong it would be way more obvious if mypy told me why it's rejecting the overload I think should be accepted (the last one in this case). There's precedent too, C++ compilers nowadays do this for overloads and it greatly helps with understanding more complex (especially Generic) code.
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 reproduciendo la llamada de ejemplo con sobrecarga e inspecciona los diagnósticos de resolución de sobrecargas de mypy. Sigue el recorrido hasta determinar dónde se produce el mensaje "Possible overload variants"; la tarea estará terminada cuando se informe de por qué se rechaza cada candidato, manteniendo el comportamiento existente cuando alguna sobrecarga coincide.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- devtools
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100