Parent modules are added as a dependency
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named in the report; start by tracing how from module.submodule import something records import dependencies and affects the cache dependency graph. Done means the import records only module.submodule, without adding the parent module or unrelated transitive dependencies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100