python / python/mypy

Parent modules are added as a dependency

Offen
#13,559 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Im Bericht werden keine Quelldateien oder Tests genannt; beginne damit nachzuverfolgen, wie from module.submodule import something Importabhängigkeiten erfasst und den Abhängigkeitsgraphen des Caches beeinflusst. Als erledigt gilt die Änderung, wenn der Import nur module.submodule erfasst, ohne das übergeordnete Modul oder unabhängige transitive Abhängigkeiten hinzuzufügen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
compilers, performance
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.