-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-129463, gh-128593: Simplify ForwardRef #129465
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
060ca69
gh-129463: gh-128593: Simplify ForwardRef
JelleZijlstra 9c1c8c8
fix test_inspect
JelleZijlstra 5d06ec5
Merge remote-tracking branch 'upstream/main' into fwdref
JelleZijlstra f59d4fb
Instead implement __eq__/__hash__ correctly
JelleZijlstra 2b26af0
fix doctest
JelleZijlstra fbb281f
update docs
JelleZijlstra 3bbf940
Merge branch 'main' into fwdref
JelleZijlstra fe665f7
Merge branch 'main' into fwdref
JelleZijlstra d273c05
fix test_types
JelleZijlstra 34c8ad5
fix test_inspect
JelleZijlstra 46593f8
Nikita comment
JelleZijlstra e71eecf
add note
JelleZijlstra 0bb5bc7
reorder
JelleZijlstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ | |
| from test.test_inspect import inspect_fodder2 as mod2 | ||
| from test.test_inspect import inspect_stringized_annotations | ||
| from test.test_inspect import inspect_deferred_annotations | ||
| from test.test_typing import EqualToForwardRef | ||
|
||
|
|
||
|
|
||
| # Functions tested in this suite: | ||
|
|
@@ -4912,7 +4913,7 @@ def test_signature_annotation_format(self): | |
| ) | ||
| self.assertEqual( | ||
| signature_func(ida.f, annotation_format=Format.FORWARDREF), | ||
| sig([par("x", PORK, annotation=ForwardRef("undefined"))]) | ||
| sig([par("x", PORK, annotation=EqualToForwardRef("undefined"))]) | ||
| ) | ||
| with self.assertRaisesRegex(NameError, "undefined"): | ||
| signature_func(ida.f, annotation_format=Format.VALUE) | ||
|
|
||
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
3 changes: 3 additions & 0 deletions
3
Misc/NEWS.d/next/Library/2025-01-29-21-27-45.gh-issue-128593.r3j4l-.rst
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| :class:`annotationlib.ForwardRef` objects no longer cache their value when | ||
| they are successfully evaluated. Successive calls to | ||
| :meth:`annotationlib.ForwardRef.evaluate` may return different values. |
4 changes: 4 additions & 0 deletions
4
Misc/NEWS.d/next/Library/2025-01-29-21-29-46.gh-issue-129463.qePexX.rst
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| :class:`annotationlib.ForwardRef` objects no longer compare or hash equal | ||
| when they refer to the same string. The implementation of equality was | ||
| error-prone because it did not take all attributes of the | ||
| :class:`!ForwardRef` object into account. |
Oops, something went wrong.
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.
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.
We can remove this
elsebranch and just write:try: return self.__cell__.cell_contentsThere 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.
Good point, sorry I missed this comment