Replace uses of deprecated imp with importlib#307
Merged
julianlocke merged 8 commits intomainfrom Jul 19, 2023
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## main #307 +/- ##
==========================================
- Coverage 52.02% 51.95% -0.08%
==========================================
Files 37 37
Lines 8451 8463 +12
Branches 1810 1811 +1
==========================================
Hits 4397 4397
- Misses 3737 3749 +12
Partials 317 317
Flags with carried forward coverage won't be shown. Click here to find out more.
|
c21d73e to
7b49e85
Compare
devPalacio
reviewed
Jul 19, 2023
Comment on lines
+370
to
385
| def _load_module(name, path): | ||
| file_name = os.path.basename(path) | ||
| module_name = file_name.replace('.', '_') | ||
|
|
||
| module_specs = importlib.util.spec_from_file_location(module_name, path) | ||
| module = importlib.util.module_from_spec(module_specs) | ||
| module_specs.loader.exec_module(module) | ||
|
|
||
| sys.modules[name] = module | ||
|
|
||
| return module | ||
|
|
Contributor
There was a problem hiding this comment.
This doesn't work for python <= 3.5, if you want to preserve the ability to run those lower versions, you can borrow inspiration from https://github.com/epfl-scitas/spack/blob/a60ae07083a5744607064221a0cd48204a54394e/lib/spack/llnl/util/lang.py#L598-L625
devPalacio
approved these changes
Jul 19, 2023
added 4 commits
July 19, 2023 13:55
Contributor
|
Fixes #295 |
julianlocke
pushed a commit
that referenced
this pull request
Jul 20, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Imp is removed in Python3.12, we should use importlib instead. This will also quiet some deprecation warnings.
Checklist
General Contributing
Is This a Code Change?
Validation
tox?