-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-124342: Wrap __annotate__ functions in functools.update_wrapper #124346
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I was just surprised that updating func.__annotations__
after update_wrapper(wrapper, func)
doesn't update wrapper.__annotations__
. Don't get me wrong, I'm fine with this behavior.
Lib/functools.py
Outdated
func = _get_get_annotations() | ||
return func(wrapped, format=format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func = _get_get_annotations() | |
return func(wrapped, format=format) | |
get_annotations = _get_get_annotations() | |
return get_annotations(wrapped, format=format) |
Another surprising behavior. I'm discovering When I update annotations of the wrapped function,
I would expect getting the same value for both cases. Either |
cc @sobolevn |
This is because we use |
functools.update_wrapper
implementation #124342📚 Documentation preview 📚: https://cpython-previews--124346.org.readthedocs.build/