gh-141174: Improve annotationlib.get_annotations() test coverage#141286
Merged
JelleZijlstra merged 5 commits intopython:mainfrom Nov 10, 2025
Merged
gh-141174: Improve annotationlib.get_annotations() test coverage#141286JelleZijlstra merged 5 commits intopython:mainfrom
annotationlib.get_annotations() test coverage#141286JelleZijlstra merged 5 commits intopython:mainfrom
Conversation
…s on custom objects
…s on wrapped partial functions
…t stringized annotations
JelleZijlstra
approved these changes
Nov 10, 2025
|
Thanks @dr-carlos for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Nov 10, 2025
…age (pythonGH-141286) * Test `get_annotations(format=Format.VALUE)` for stringized annotations on custom objects * Test `get_annotations(format=Format.VALUE)` for stringized annotations on wrapped partial functions * Update test_stringized_annotations_with_star_unpack() to actually test stringized annotations * Test __annotate__ returning a non-dict * Test passing globals and locals to stringized `get_annotations()` (cherry picked from commit 06b6228) Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com>
|
GH-141353 is a backport of this pull request to the 3.14 branch. |
JelleZijlstra
pushed a commit
that referenced
this pull request
Nov 10, 2025
…rage (GH-141286) (#141353) gh-141174: Improve `annotationlib.get_annotations()` test coverage (GH-141286) * Test `get_annotations(format=Format.VALUE)` for stringized annotations on custom objects * Test `get_annotations(format=Format.VALUE)` for stringized annotations on wrapped partial functions * Update test_stringized_annotations_with_star_unpack() to actually test stringized annotations * Test __annotate__ returning a non-dict * Test passing globals and locals to stringized `get_annotations()` (cherry picked from commit 06b6228) Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com>
|
Contributor
Author
This seems to be a false positive - obviously this commit doesn't touch |
Member
|
Petr said that that test is being disabled on buildbots, it's frequently flaky. |
StanFromIreland
pushed a commit
to StanFromIreland/cpython
that referenced
this pull request
Dec 6, 2025
…age (python#141286) * Test `get_annotations(format=Format.VALUE)` for stringized annotations on custom objects * Test `get_annotations(format=Format.VALUE)` for stringized annotations on wrapped partial functions * Update test_stringized_annotations_with_star_unpack() to actually test stringized annotations * Test __annotate__ returning a non-dict * Test passing globals and locals to stringized `get_annotations()`
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.
All lines in
get_annotations(),_rewrite_star_unpack(), and_get_and_call_annotate()should now be covered by tests.Branch coverage for evaluating stringized annotations on classes with no module or a module which cannot be imported was intentionally not included, as I couldn't find a realistic case and it didn't seem like a behaviour that needed to be reproducible. Happy to add a new test for this.
Also happy to remove the test which covers the branch of 'what if we unwrap a partial object but functools has never been imported', as this isn't a very realistic situation either.