Skip to content

Replace uses of deprecated imp with importlib#307

Merged
julianlocke merged 8 commits intomainfrom
remove-imp
Jul 19, 2023
Merged

Replace uses of deprecated imp with importlib#307
julianlocke merged 8 commits intomainfrom
remove-imp

Conversation

@julianlocke
Copy link
Copy Markdown
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
Copy Markdown

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%> (ø)

@julianlocke julianlocke changed the base branch from main to fix-ci-checks July 18, 2023 22:05
Comment thread stone/cli.py
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
Copy Markdown
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
@julianlocke julianlocke merged commit af56116 into main Jul 19, 2023
@julianlocke julianlocke deleted the remove-imp branch July 19, 2023 20:05
@devPalacio
Copy link
Copy Markdown
Contributor

Fixes #295

julianlocke pushed 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 <jaypalacio@gmail.com>
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