[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_moduleload_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_moduleis deprecated and will be replaced byexec_modulein 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_moduleis highly unhelpful, and I had to reverse engineer this from a very helpful PR innox, wntrblm/nox#498