mypy sometimes emits fewer errors when running on multiple files at once
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Decomprimi repro.zip ed esegui i due comandi del report con foo.py e bar.py per riprodurre le diagnosi differenti. Traccia come vengono gestiti gli import di mymodule.a e mymodule.b quando i file vengono controllati insieme, quindi assicurati che l'errore relativo all'attributo mancante continui a essere segnalato in entrambe le invocazioni.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100