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 larry
Recipients larry, rhettinger
Date 2022-02-24.09:47:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645696033.77.0.27320800273.issue46847@roundup.psfhosted.org>
In-reply-to
Content
functools.update_wrapper currently copies over every attribute listed in the "assigned" parameter, which defaults to WRAPPER_ASSIGNMENTS, which means it copies the wrapped function's __annotations__ to the wrapper.  This is slightly wrong if the wrapper occludes an annotated parameter:

    def foo(a: int, b: str, c: float):
        print(a, b, c)

    import functools

    foo_a = functools.partial(foo, 3)
    functools.update_wrapper(foo_a, foo)

    print(foo_a.__annotations__)

In this case, foo_a.__annotations__ contains an annotation for a parameter named "a", even though foo_a doesn't have a parameter named "a".

This problem occurred to me just after I filed #46846; the two issues are definitely related.
History
Date User Action Args
2022-02-24 09:47:13larrysetrecipients: + larry, rhettinger
2022-02-24 09:47:13larrysetmessageid: <1645696033.77.0.27320800273.issue46847@roundup.psfhosted.org>
2022-02-24 09:47:13larrylinkissue46847 messages
2022-02-24 09:47:13larrycreate