Always import from sphinx.ext.autodoc.mock module instead of relying on implicit import resolution#160
Open
dionhaefner wants to merge 2 commits intoclick-contrib:masterfrom
Open
Always import from sphinx.ext.autodoc.mock module instead of relying on implicit import resolution#160dionhaefner wants to merge 2 commits intoclick-contrib:masterfrom
dionhaefner wants to merge 2 commits intoclick-contrib:masterfrom
Conversation
…on implicit import resolution
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.
Summary
Fixes #159
The problem is that some extensions (like
sphinx_autodoc_typehints) run this:This causes
sphinx_clickto resolve its own import ofmockdifferently, which uses:Before running
from sphinx.ext.autodoc.mock import mock, this resolves to the mock function. After, it resolves to the mock module. This is an inherent property of the Python resolution mechanism where the module is added as an attribute of the parent module once imported.The easiest fix to me is to side-step the issue and import from the
sphinx.ext.autodoc.mockmodule explicitly, which is what this PR implements. This module has existed at least since Sphinx 4.0.0 (current minimum version of Sphinx) so should be backwards compatible.Tasks
Added documentation for new features (where applicable)reno)tox)Further details