rndusr / torf

Python module to create, parse and edit torrent files and magnet links
GNU General Public License v3.0
179 stars 18 forks source link

Alternative to `__all__` #51

Closed Ravencentric closed 1 week ago

Ravencentric commented 1 week ago

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:

  1. Define __all__ in both __init__.pyi and __init__.py to explicitly tell typecheckers and IDEs what torf exports
  2. 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
Ravencentric commented 1 week ago

I've made two PRs, both of which fix this. Feel free to pick whichever one you prefer and close the other one.