Fix: autodoc: __wrapped__ functions are not documented correctly
#7222
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.
Bugfix
Related: #7189 (not caused by, and just fixed with #7189)
Maybe related: #6573
Functions that are decorated with
@lru_cacheor otherfunctoolsdecorators may not even be detected as a function. This results in the documentation not having the()or even trying to render the function signature.This change updates the
sphinx.util.inspectcode to unwrap__wrapped__functions before determining if they can be documented.@lru_cacheand its associated test is an example of a decorated function that is incorrectly identified as an attribute rather than a module level function and when rendering the signature (upon changingisattributedescriptor) the decorated function is still incorrectly identified as a C function.This change also renames the newly introduced
unwrapasunwrap_allbecause it is different than the prexisting Python suppliedinspect.unwrap.See
update_wrapper"Changed in version 3.4" for more background: https://docs.python.org/3/library/functools.html#functools.update_wrapper