Improve mypy --pretty output for (multiline) f-strings
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
Error messages merely say the line number, which is not always accurate - e.g. for multiline strings it's merely the first or last line of the overall multiline string (depending on Python version). If it's a format string and there's dozens of {} elements embedded in it, maybe across hundreds of lines, it can be practically impossible to tell what mypy is referring to. e.g. here's the actual output from a current problem:
src.py:136: error: "str" has no attribute "expression" [attr-defined]
src.py:136: error: Item "str" of "Optional[str]" has no attribute "expression" [union-attr]
src.py:136: error: Item "None" of "Optional[str]" has no attribute "expression" [union-attr]
src.py:136: error: Item "float" of "Optional[float]" has no attribute "expression" [union-attr]
src.py:136: error: Item "None" of "Optional[float]" has no attribute "expression" [union-attr]
src.py:136: error: "float" has no attribute "expression" [attr-defined]
src.py:136: error: "bool" has no attribute "expression" [attr-defined]
src.py:136: error: "int" has no attribute "expression" [attr-defined]
The multiline string these are embedded in is nearly a hundred lines long and has dozens of embedded elements, almost all of which reference an espression attribute. I genuinely have no idea which ones these messages are referring to. If it at least told me the name of the variable (or whatever), I'd be able to narrow it down.
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 rastreando la representación de diagnósticos de mypy con --pretty para los errores que surgen en f-strings multilínea; compara la ubicación indicada con la expresión incrustada que lo desencadenó. Se considera terminado cuando la salida pretty identifica la expresión o variable relevante del f-string, en lugar de indicar únicamente la línea del string completo.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100