Cannot ignore type errors in multiline 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
stringy = "foo"
f"""\
{stringy.nope()}
""" # type: ignore
(ignore that this is a true positive - my real code is much more complicated and is actually valid, the above is just a contrived example to show the core problem)
In Python 3.7 with mypy 0.782, it reports the error on the closing """ (if you remove the # type: ignore), so it picks up the ignore directive and all is well. In Python 3.8, it reports the error on the previous line. There's no way to add # type: ignore on that line, and adding it anywhere else has no effect.
In other cases it tends to report the error as being on the line with the opening """… I'm not sure why in this particular, contrived example it behaves differently. But either way, it's a major problem, since there's no practical workaround for this [in my much larger, real-world code]. It's blocking the upgrade to Python 3.8 for one of my major projects.
(the output from mypy w/ Python 3.8)
test.py:4: error: "str" has no attribute "nope"
Found 1 error 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
Reproduce el informe con el fragmento de test.py proporcionado usando Python 3.8 y mypy 0.782, y después compara la ubicación del diagnóstico con Python 3.7. Rastrea los diagnósticos de los f-strings multilínea y el tratamiento de # type: ignore; se considera terminado cuando el ignore de la cadena con triples comillas de cierre suprime de forma coherente el error informado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100