`attr-defined` on modules depends on imports in other files
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
I'm not sure how to put together a good description of this, but here goes: mypy emits attr-defined errors (correctly) when importing concurrent (but not concurrent.futures), and then using concurrent.futures. However, if checking another file in the same pass which does import concurrent.futures, it doesn't emit an error for the first file.
To Reproduce
Create file a.py:
import concurrent
concurrent.futures
Create file b.py:
import concurrent.futures
concurrent.futures
Expected Behavior
Should emit an error for a.py, regardless of which other files are also being checked:
$ python -m mypy --no-incremental --cache-dir=/dev/null a.py
a.py:3: error: Module has no attribute "futures" [attr-defined]
Found 1 error in 1 file (checked 1 source file)
$ python3 -m mypy --no-incremental --cache-dir=/dev/null a.py b.py
a.py:3: error: Module has no attribute "futures" [attr-defined]
Found 1 error in 1 file (checked 2 source files)
Actual Behavior
$ python -m mypy --no-incremental --cache-dir=/dev/null a.py
a.py:3: error: Module has no attribute "futures" [attr-defined]
Found 1 error in 1 file (checked 1 source file)
$ python -m mypy --no-incremental --cache-dir=/dev/null a.py b.py
Success: no issues found in 2 source files
Your Environment
- Mypy version used: tried both 1.11.2 and mypy-1.12.0+dev.0412590ba13395a04f122a5dd83764db9d001fe6
- Mypy command-line flags:
--no-incremental --cache-dir=/dev/null, just because it's less confusing that way. I was also seeing this with caching - Mypy configuration options from
mypy.ini(and other config files): None - Python version used: 3.8
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
Riproduci il problema con i file forniti a.py e b.py, usando python -m mypy --no-incremental --cache-dir=/dev/null su ciascun file e su entrambi insieme. Inizia tracciando la gestione degli attributi dei moduli durante il controllo di più file; il lavoro è terminato quando a.py segnala costantemente l'attributo futures mancante, indipendentemente dal fatto che b.py venga controllato o meno.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers, tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100