Parent modules are added as a dependency
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
It seems that since #4498, when you do from module.submodule import something, Mypy adds a reference both to module.submodule AND to module. If in addition module imports functionalities from its submodules, then all of them become transitive dependencies, and so on.
The end result of this is that the SCC ends including almost every file in my library, so when I modify ANYTHING the cache is discarded and must be rebuilt again from almost zero, causing unbearable static analysis times.
Supposedly, the dependency to the parent module is more correct from a semantic point of view, as Python executes that module before importing the submodule. However by the same logic all parents should be added as dependencies, and this is not done. Given the current implementation it could be possible to break the dependencies by putting each module in its own folder, so either I am missing something or that logic makes no sense at all.
To Reproduce
Any import of module.submodule causes a dependency on module.
Expected Behavior
If a submodule is imported, the dependency should be on that submodule ONLY.
Actual Behavior
A bogus dependency to module is added.
Your Environment
- Mypy version used: mypy 0.971 (compiled: yes)
- Mypy command-line flags: Irrelevant AFAIK
- Mypy configuration options from
mypy.ini(and other config files): Irrelevant AFAIK - Python version used: 3.8
- Operating system and version: Linux Ubuntu 18.04.6 LTS
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
Nel report non sono indicati file sorgente o test; inizia tracciando il modo in cui from module.submodule import something registra le dipendenze di importazione e influisce sul grafo delle dipendenze della cache. Il lavoro è completato quando l’importazione registra solo module.submodule, senza aggiungere il modulo principale o dipendenze transitive non correlate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers, performance
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100