Let stub-defined __all__ override imports#133
Let stub-defined __all__ override imports#133lagru wants to merge 1 commit intoscientific-python:mainfrom
__all__ override imports#133Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #133 +/- ##
==========================================
- Coverage 95.74% 93.63% -2.12%
==========================================
Files 5 5
Lines 235 267 +32
==========================================
+ Hits 225 250 +25
- Misses 10 17 +7 ☔ View full report in Codecov by Sentry. |
This enables the use case where objects should be available for lazy-loading while not advertising them. This might be useful for deprecations.
464728f to
9579004
Compare
|
Could that be a simpler approach, here, simply adding a |
Probably? There might be tools out there to find the public API that way. Can't remember how Sphinx does it, but probably with |
In scikit-image, I encountered the case where I want to make certain functions available for lazy-loading while at the same time not wanting to advertise their existence via
__all__(see scikit-image/scikit-image#6892). To implement this with the current behavior oflazy_loader.attach_stubI had to specify__all__twice, both in the PY and in the PYI file (see scikit-image/scikit-image@40157d0).Ideally, I'd like to avoid this duplication. So I came up with a quick "work in progress" solution, in order to discuss this use case here. The current draft has some drawbacks for now, e.g. it makes certain assumptions about how
__all__must be defined in the stub. I'm happy to iterate on this, depending on which kind of behavior is wanted.Please, let me know what you think. 😊