-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-132064: Make annotationlib use __annotate__ if only it is present #132195
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-132064: Make annotationlib use __annotate__ if only it is present #132195
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.
haven't looked too deeply yet
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.
Looks good. Is it worth also adding an integration test to test_functools.py
, covering the original way this issue was discovered?
|
Fixes #132064. Non-function objects for which
update_wrapper()
was used end up with only__annotate__
, not__annotations__
. It seems sensible forget_annotations()
to support this case, and that also fixes the issue that was reported.While implementing this I noticed a discrepancy between the docs and behavior of
get_annotations()
. The documentation said that the function would raise on unsupported objects; in fact it returned an empty dictionary, except ifeval_str=True
. I made it consistently raise a TypeError in this case instead, consistent with the docs.singledispatch.register
fails forlru_cache
decorated functions #132064📚 Documentation preview 📚: https://cpython-previews--132195.org.readthedocs.build/