This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Thor Whalen
Recipients JelleZijlstra, Thor Whalen, Thor Whalen2, domdfcoding, donovick, gregory.p.smith, ncoghlan, terry.reedy
Date 2021-05-03.19:52:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CANryRXBVeH0PduHW7wi+9SX50rCmqUs-4e7WWpyTTXPr4WB85Q@mail.gmail.com>
In-reply-to <1619931159.44.0.995284665324.issue41232@roundup.psfhosted.org>
Content
On the surface, seems like a fair design to me: Back-compatible yet solves
this misalignment that bugged me (literally).
It would also force the documentation of `functools.wraps` to mention this
"trap", through describing the `signature_changed` flag.
As for the `__wrapped_with_changed_signature__`; yes, it's terrible. But I
have no better. At least, it's very descriptive!

On Sat, May 1, 2021 at 9:52 PM Jelle Zijlstra <report@bugs.python.org>
wrote:

>
> Jelle Zijlstra <jelle.zijlstra@gmail.com> added the comment:
>
> We could add a new argument to `@functools.wraps()` to differentiate
> between a wrapper with the same signature and one with a different
> signature.
>
> Here's a possible design:
> * functools.wraps adds a new keyword-only argument signature_changed. It
> defaults to False for backward compatibility.
> * If signature_changed is True:
>   * __annotations__ are not copied
>   * __wrapped__ is not set on the wrapping function. Instead, we set a new
> attribute __wrapped_with_changed_signature__ (that's a pretty terrible
> name, open to suggestions). This will make inspect.signature not look at
> the wrapped function.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue41232>
> _______________________________________
>
History
Date User Action Args
2021-05-03 19:52:34Thor Whalensetrecipients: + Thor Whalen, terry.reedy, gregory.p.smith, ncoghlan, JelleZijlstra, donovick, domdfcoding
2021-05-03 19:52:34Thor Whalenlinkissue41232 messages
2021-05-03 19:52:33Thor Whalencreate