Display the correct signature for a decorated function in Python 3 #765
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.
This patch changes it so that
inspect.signature
is used instead ofinspect.getfullargspec
to get a function's signature, when using Python 3.Python 3.3 introduced the
inspect.signature
function as a new way to get thesignature of a function (as an alternative to
inspect.getargspec
andinspect.getfullargspec
).inspect.signature
has the advantage that itpreserves the signature of a decorated function if
functools.wraps
is used todecorated the wrapper function. Having a function's signature available is very
hepful, especially when testing things out in a REPL.
The below images show the change in action (first the old behavior, then the new one):
I was only able to test the changes on Python 3.7.2, but since all used functionality is available since Python 3.3 (and I only touch code paths used on Python 3) I don't think anything should break on other versions.