-
Notifications
You must be signed in to change notification settings - Fork 357
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
Concise and static Python imports #2135
Conversation
23ecca6
to
4c16e07
Compare
This comment has been minimized.
This comment has been minimized.
And used generator expression since we're py3.8+ now 🎉
ae78097
to
753d30b
Compare
* Caused code duplication (__all__) * Is a maintenance burden * Namespace pollution
@jougs I hope you don't mind I went ahead and removed The change could have affected users that do funky things with deep imports, but I just added |
No worries! I'm always in favor of cleaning things up and not adding backwards-compatibility-cruft. As this PR won't make it into 3.1, I suggest, you create another small PR, adding a sentence to the release notes that the |
(side note on #2157 to @jougs and in general also for @heplesser and others related to the modules) All of our problems with the reference to the old nest module seem to be disguised circular import errors that due to a bug in Python makes it pick up the unreplaced module object that it compiled and executed in order to even get to the point in I think the codebase should be thoroughly vetted for code that gets executed at import time and also the nest submodules should not import |
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.
Other than my few comments (that were likely triggered by my ignorance about how pytest works) I'm fine with this. Thanks for the nice contribution :-)
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.
Thanks for the nice contribution and the fruitful discussion.
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.
@Helveg Looks generally good to me, just two small suggestions.
Co-authored-by: Hans Ekkehard Plesser <hans.ekkehard.plesser@nmbu.no>
Removed all forms of dynamic module importing and
from X import *
. If the need for dynamic modules arises again they can be defined as a lazy loaded module such asspatial
with some extra indications for the user when missing optional modules are accessed:PR summary
ast
/compile
based dynamic importing byimportlib
.ast
/compile
sidesteps import machinery._lazy_module_property("feature", optional=True, optional_hint="Please install feature.")
hl_api
from X import *
calls with explicit imports.