stubtest misses the presence of submodules in the top level of module when `from .submod import *` used to reexport submodules in `__init__.pyi`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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.
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
Reproduce the report with a package whose init.pyi uses from .submod import * and lists submodules in __all__; start by tracing stubtest's handling of these exports. Done means stubtest recognizes runtime-bound submodules without emitting one missing-submodule diagnostic per entry, with regression coverage for the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100