-
Notifications
You must be signed in to change notification settings - Fork 15
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] address deprecation of load_module
#190
Conversation
FYI @yarnabrina - perhaps you see a quick fix to this? I'm not sure what to replace the deprecated logic by, is the problem. |
Sorry, I have not used https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly If you can explain me what you are trying to do, for example why the |
Re the "what", the issue is simply that |
load_module
load_module
for posterity, this was highly non-trivial. Any line spec = importlib.util.spec_from_file_location(module.name, module.path)
imported_mod = importlib.util.module_from_spec(spec)
# these two are also crucial due to the side effects
loader = spec.loader
loader.exec_module(imported_mod) The deprecation message raised by |
Codecov ReportAll modified lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #190 +/- ##
=======================================
Coverage 83.60% 83.60%
=======================================
Files 43 43
Lines 2843 2843
=======================================
Hits 2377 2377
Misses 466 466
☔ View full report in Codecov by Sentry. |
load_module
is deprecated and will be replaced byexec_module
in python 3.12, this PR addresses that.The fix is highly nontrivial - the crucial line was
imported_mod = module.load_module()
for amodule: SourceFileLoader
,which had to be replaced by the equivalent four (!) lines
The deprecation message raised by
load_module
is highly unhelpful, and I had to reverse engineer this from a very helpful PR innox
, wntrblm/nox#498