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

Switch uses of __import__ to importlib.get_module() #6653

Merged
merged 1 commit into from
Aug 18, 2019
Merged

Switch uses of __import__ to importlib.get_module() #6653

merged 1 commit into from
Aug 18, 2019

Conversation

jdufresne
Copy link
Contributor

The Python docs for __import__ recommend using importlib.get_module().

https://docs.python.org/3/library/functions.html#__import__

Note: This is an advanced function that is not needed in everyday Python programming, unlike importlib.import_module().

As importlib.get_module() uses the Python module cache and returns the module, this also allows simplifying many module cache checks of use of sys.modules.

importlib.get_module() has been available since Python 3.3.

@codecov
Copy link

codecov bot commented Aug 17, 2019

Codecov Report

Merging #6653 into 2.0 will increase coverage by 0.01%.
The diff coverage is 94.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##              2.0    #6653      +/-   ##
==========================================
+ Coverage   83.75%   83.76%   +0.01%     
==========================================
  Files         266      266              
  Lines       40893    40894       +1     
  Branches     5996     5995       -1     
==========================================
+ Hits        34250    34255       +5     
+ Misses       5320     5317       -3     
+ Partials     1323     1322       -1
Impacted Files Coverage Δ
sphinx/ext/coverage.py 81.77% <100%> (+0.09%) ⬆️
sphinx/highlighting.py 86.36% <100%> (+0.12%) ⬆️
sphinx/registry.py 75% <100%> (+0.17%) ⬆️
sphinx/search/__init__.py 96.06% <100%> (+0.01%) ⬆️
sphinx/ext/inheritance_diagram.py 81.3% <100%> (-0.8%) ⬇️
sphinx/ext/autodoc/importer.py 92.63% <100%> (-0.08%) ⬇️
sphinx/deprecation.py 69.04% <100%> (+3.13%) ⬆️
tests/test_ext_autodoc_mock.py 100% <100%> (ø) ⬆️
sphinx/util/__init__.py 71.07% <75%> (+0.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf573ae...ecb1e76. Read the comment docs.

Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

LGTM. Could you rebase this into 2.0 branch?

@tk0miya tk0miya added this to the 2.2.0 milestone Aug 17, 2019
@jdufresne jdufresne changed the base branch from master to 2.0 August 17, 2019 18:43
The Python docs for __import__ recommend using importlib.get_module().

https://docs.python.org/3/library/functions.html#__import__

> Note: This is an advanced function that is not needed in everyday
> Python programming, unlike importlib.import_module().

As importlib.get_module() uses the Python module cache and returns the
module, this also allows simplifying many module cache checks of use of
sys.modules.

importlib.get_module() has been available since Python 3.3.
@jdufresne
Copy link
Contributor Author

Sure thing. Rebased.

Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

Thank you for quick work!

@tk0miya tk0miya merged commit 4e12d4b into sphinx-doc:2.0 Aug 18, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants