-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MNT: add __all__ to top level module #680 #683
Conversation
Thanks @Kirill888 👍, have you verified that this addresses the issue? I am still wondering if this is more of a pylance issue and less of a rioxarray issue. Side tangent: I am not a fan of https://docs.python.org/3/tutorial/modules.html#importing-from-a-package
|
Sure I see I think maintenance burden of this is minimal, |
Thanks for your thoughts on I think Other ranting to feel free to ignore 😄 :
|
"open_rasterio", | ||
"set_options", | ||
"show_versions", | ||
"__author__", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure __author__
and __version__
are useful to add to __all__
? I was thinking only functions without an _
in the prefix should be added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, if one thinks of it as "a list of exported symbols", then yes. Pylint and numpy DO include __version__
in __all__
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to stare at worms sometimes 👁️ 🪱 🪱 😄 .
I agree it's a bit annoying to have that separation between implementation and "extern" marker. I guess this is one of the trade-offs of using highly dynamic multi-paradigm language - community needs to develop and apply conventions that are not enforced by a strict spec and type system. And those conventions evolve over time, __all__
might have started as a mechanism for controlling star imports, but it is now used by various code analysis tools as well, even if it's not official enough to be reflected in official language docs and not adopted by all of the popular libraries. I also won't be surprised if mypy
offers something in that space as well, that maybe, requests
is using instead?
There are probably tools already out there that help with the issue of keeping __all__
in sync with the code. I never looked, as it's not a pain-point for me. I do forget to define __all__
in public sub-modules that have method implementations in them, and usually linting tools are lenient and use leading _
as a heuristic for deciding on public interface, so no one notices any issues. I also forget to add new public methods to sphinx docs, but I still think that explicit decision on what should and should not be documented, should or should not be considered part of the public interface is a reasonable approach. Sure, it costs a little bit extra at "create/maintain" stage, but also benefits "use" stage enough to bother.
I usually do not forget to add __all__
in __init__.py
files that have no implementation code because of unused-import
warning pylint
generates in this case. I have been slowly moving towards having private sub-modules with explicit public interface sub-modules that just import and re-export methods from internal implementations, as this allows for greater flexibility in refactoring.
Thanks again @Kirill888 👍 |
docs/history.rst
for all changes anddocs/rioxarray.rst
for new API