scikit-build icon indicating copy to clipboard operation
scikit-build copied to clipboard

why is __all__ required

Open blackliner opened this issue 3 years ago • 3 comments

We want to avoid the maintaineance overhead of listing all symbols in __init__.py's __all__, but it seems to be a special scikit-build thing? We do not use the from module import * way of importing, which should be the only reason to use __all__ at all.

blackliner avatar Feb 16 '22 17:02 blackliner

__all__ is from Python, not scikit-build. It is how you tell Python and your reader what is "public" in your module. __all__ is also used by static analysis tools to detect usages of things that are not "public" (like mypy and others). It's also a "table of contents" to the reader. If you define def __dir__(): return __all__, then you get correct tab completion for your public API, things like module imports (!) will stop showing up (Python 3.7+).

Scikit-build does not read __all__ as far as I can tell: https://github.com/scikit-build/scikit-build/search?q=__all__

henryiii avatar Feb 18 '22 15:02 henryiii

What I meant was: with setuptools, I do not need __all__, but with scikit-build it must be defined, otherwise the library will not be consumable. So the build parameters seem to be off from what setuptools does?

blackliner avatar Feb 22 '22 07:02 blackliner

Why must it be defined? I've already pointed out it's not accessed anywhere in scikit-build's code base, and I'm pretty sure I have never had to add an __all__ (though it's always a good idea, I'm often lazy and forget it).

henryiii avatar Feb 23 '22 15:02 henryiii