stubtest misses the presence of submodules in the top level of module when `from .submod import *` used to reexport submodules in `__init__.pyi`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
In my package's __init__.py, when I list the names of all my submodules along with the functions imported from them in __all__, such that from pkg import * would make the submodule objects available in the global namespace as well, stubtest thinks the submodules are missing, meaning __all__ is inconsistent with what happens at runtime.
However, python's import machinery means that loading a submodule binds it to the parent module as an attribute with the same name. This is how when you import a submodule in any way, it is accessible by dotted name on the parent module, so there is nothing wrong with including the submodules in my __all__, and in my case an intended behaviour. This is significant since stubtest annoyingly produces one diagnostic per submodule, and including them in allowlist may shadow other issues.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere den Bericht mit einem Paket, dessen init.pyi from .submod import * verwendet und Submodule in __all__ auflistet; beginne damit, die Verarbeitung dieser Exporte durch stubtest nachzuverfolgen. Als erledigt gilt die Aufgabe, wenn stubtest zur Laufzeit gebundene Submodule erkennt, ohne für jeden Eintrag eine eigene Diagnose zu einem fehlenden Submodul auszugeben, und eine Regressionstestabdeckung für diesen Fall vorhanden ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 55/100