gh-132064: Make annotationlib use __annotate__ if only it is present#132195
Merged
JelleZijlstra merged 5 commits intopython:mainfrom Apr 13, 2025
Merged
gh-132064: Make annotationlib use __annotate__ if only it is present#132195JelleZijlstra merged 5 commits intopython:mainfrom
JelleZijlstra merged 5 commits intopython:mainfrom
Conversation
AlexWaygood
reviewed
Apr 7, 2025
Member
AlexWaygood
left a comment
There was a problem hiding this comment.
haven't looked too deeply yet
AlexWaygood
reviewed
Apr 10, 2025
Member
AlexWaygood
left a comment
There was a problem hiding this comment.
Looks good. Is it worth also adding an integration test to test_functools.py, covering the original way this issue was discovered?
AlexWaygood
approved these changes
Apr 10, 2025
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.registerfails forlru_cachedecorated functions #132064📚 Documentation preview 📚: https://cpython-previews--132195.org.readthedocs.build/