Although typecheckers don't complain about the lack of __all__ within the package itself (hence why I failed to catch this initially, sorry!), they do complain about it when one imports a typed package into their own. That means when I use torf in my own library like from torf import Torrent type checkers complain that Torrent is an unknown attribute and they bail out (essentially making the stubs useless). This has two work arounds:
Define __all__ in both __init__.pyi and __init__.py to explicitly tell typecheckers and IDEs what torf exports
Change from ._torrent import Torrent to from ._torrent import Torrent as Torrent in __init__.pyi (__init__.py can be left untouched). This relies on the fact that X as X is a heuristic that typecheckers use to determine if the package wants to export X as a part of the public API
Although typecheckers don't complain about the lack of
__all__
within the package itself (hence why I failed to catch this initially, sorry!), they do complain about it when one imports a typed package into their own. That means when I use torf in my own library likefrom torf import Torrent
type checkers complain thatTorrent
is an unknown attribute and they bail out (essentially making the stubs useless). This has two work arounds:__all__
in both__init__.pyi
and__init__.py
to explicitly tell typecheckers and IDEs what torf exportsfrom ._torrent import Torrent
tofrom ._torrent import Torrent as Torrent
in__init__.pyi
(__init__.py
can be left untouched). This relies on the fact thatX as X
is a heuristic that typecheckers use to determine if the package wants to exportX
as a part of the public API