-
Notifications
You must be signed in to change notification settings - Fork 413
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
Improve some import handling #1928
Conversation
) This avoids importing metpy.calc and metpy.plots in the metar parsing code, which improves import times for code that's only doing unrelated I/O, as well as eliminates a warning when CartoPy is not installed. The wx_code_map and wx_code_to_numeric function should eventually be moved to metar.py, but that's an API change.
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.
Good to go. If it doesn't matter for directly-accessed plots.__dir__()
to be sorted, you can drop that. dir(plots)
and iPython tab-completion already return sorted. Don't envision it hurting to leave in.
Thanks for catching that, it was an erroneous copy from this PEP. I fixed, and addressed a couple things the bots pointed out. Let's see now if the failure path for |
This should be fully tested now and ready for final review. |
Ugh, failed on build without CartoPy installed. Fixed. |
While looking elsewhere, I was inspired and decided that instead of logging a warning about needing Cartopy, it should just be part of the |
Use the module-level __getattr__ support in Python 3.7 to dynamically handle access to the CartoPy map features and only warn *upon use* if CartoPy isn't installed.
Description Of Changes
metpy.io.metar
. This is currently causing importingmetpy.io
to trigger imports ofmetpy.calc
andmetpy.plots
, which can add almost half a second to the total import and currently triggers warnings when Cartopy isn't installed__getattr__()
we have available now that we're only supporting Python >=3.7.Checklist
Level3File
import is a bit bloated #1901