Skip to content
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

Replace uses of deprecated imp with importlib #307

Merged
merged 8 commits into from
Jul 19, 2023
Merged

Replace uses of deprecated imp with importlib #307

merged 8 commits into from
Jul 19, 2023

Conversation

julianlocke
Copy link
Contributor

@julianlocke julianlocke commented Jul 18, 2023

Imp is removed in Python3.12, we should use importlib instead. This will also quiet some deprecation warnings.

Checklist

General Contributing

  • Have you read the Code of Conduct and signed the CLA?

Is This a Code Change?

  • Non-code related change (markdown/git settings etc)
  • Code Change
  • Example/Test Code Change

Validation

  • Have you ran tox?
  • Do the tests pass?

@codecov
Copy link

codecov bot commented Jul 18, 2023

Codecov Report

Merging #307 (255a3d6) into main (82ee5e3) will decrease coverage by 0.08%.
The diff coverage is 6.25%.

❗ Current head 255a3d6 differs from pull request most recent head a7046ce. Consider uploading reports for the commit a7046ce to get more accurate results

@@            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              
Flag Coverage Δ
unit 51.95% <6.25%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
stone/cli.py 0.00% <0.00%> (ø)
stone/ir/api.py 82.11% <100.00%> (ø)

stone/cli.py Outdated
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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Base automatically changed from fix-ci-checks to main July 19, 2023 16:01
@devPalacio
Copy link
Contributor

Fixes #295

julianlocke added a commit that referenced this pull request Jul 20, 2023
* Fix ci: pin linux, pin flake8, ignore type error, fix mypy (#308)

* Replace uses of deprecated imp with importlib (#307)

* Update cli.py to work with java sdk (#310)

---------

Co-authored-by: Jay <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants