mypy sometimes emits fewer errors when running on multiple files at once
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
Hello there,
I am witnessing (rare) cases where mypy emits fewer errors when running on multiple files at the same time than when running on each file individually.
More specifically, I noticed that mypy can fail to report an error when an import for a submodule is missing a one file but present in another file.
I failed to find anything relevant in the documentation or in the existing issues, so I thought I'd let you know. Below is my attempt at a minimal reproducible example.
To Reproduce
(Since multiple files are needed, here is an archive with the reproduction case: repro.zip)
Given a module mymodule with nested modules a and b, and this file foo.py:
import mymodule.a
def blah() -> None:
mymodule.b.fn()
blah()
As expected, when called on foo.py, mypy emits an error:
$ mypy --cache-dir /dev/null foo.py
foo.py:5: error: Module has no attribute "b"
Found 1 error in 1 file (checked 1 source file)
yet if I add to mypy's command line a second file which does import mymodule.b, say bar.py:
import mymodule.b
then mypy does not emit the error any more, even though I would expect it to:
$ mypy --cache-dir /dev/null foo.py bar.py
Success: no issues found in 2 source files
Your Environment
I used mypy 0.991 on Ubuntu 22.04 with python 3.10.6; I can reproduce this behavior with master, as well as python 3.8, and older versions of mypy.
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
Descomprime repro.zip y ejecuta los dos comandos del informe con foo.py y bar.py para reproducir los diagnósticos diferentes. Rastrea cómo se gestionan las importaciones de mymodule.a y mymodule.b cuando los archivos se comprueban juntos y, a continuación, asegúrate de que el error de atributo ausente se siga informando en ambas invocaciones.
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