Consider a module like
foo/
__init__.py
__init__.pyi
bar.py
baz.py
Where __init__.py is
import lazy_loader as lazy
# this assumes there is a `.pyi` file adjacent to this module
__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
__init__.pyi is
from .bar import *
from .baz import *
https://typing.readthedocs.io/en/latest/source/stubs.html#imports says that * imports are re-exported. Therefore lazy.attach_stub should resolve the star imports from bar.py and baz.py. Instead foo.__all__ == [*].