Skip to content

Parent modules are added as a dependency #13559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vnmabus opened this issue Aug 30, 2022 · 0 comments
Open

Parent modules are added as a dependency #13559

vnmabus opened this issue Aug 30, 2022 · 0 comments
Labels
bug mypy got something wrong

Comments

@vnmabus
Copy link

vnmabus commented Aug 30, 2022

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
@vnmabus vnmabus added the bug mypy got something wrong label Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant