Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5e80fee

Browse files
gh-129463: Remove two attributes from ForwardRef equality (#132283)
1 parent884df11 commit5e80fee

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

‎Lib/annotationlib.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ def __eq__(self, other):
225225
# because dictionaries are not hashable.
226226
andself.__globals__isother.__globals__
227227
andself.__forward_is_class__==other.__forward_is_class__
228-
andself.__code__==other.__code__
229-
andself.__ast_node__==other.__ast_node__
230228
andself.__cell__==other.__cell__
231229
andself.__owner__==other.__owner__
232230
)
@@ -237,8 +235,6 @@ def __hash__(self):
237235
self.__forward_module__,
238236
id(self.__globals__),# dictionaries are not hashable, so hash by identity
239237
self.__forward_is_class__,
240-
self.__code__,
241-
self.__ast_node__,
242238
self.__cell__,
243239
self.__owner__,
244240
))

‎Lib/test/test_typing.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6539,6 +6539,13 @@ def test_or(self):
65396539
self.assertEqual(X|"x",Union[X,"x"])
65406540
self.assertEqual("x"|X,Union["x",X])
65416541

6542+
deftest_multiple_ways_to_create(self):
6543+
X1=Union["X"]
6544+
self.assertIsInstance(X1,ForwardRef)
6545+
X2=ForwardRef("X")
6546+
self.assertIsInstance(X2,ForwardRef)
6547+
self.assertEqual(X1,X2)
6548+
65426549

65436550
classInternalsTests(BaseTestCase):
65446551
deftest_deprecation_for_no_type_params_passed_to__evaluate(self):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Comparison of:class:`annotationlib.ForwardRef` objects no longer uses the
2+
internal ``__code__`` and ``__ast_node__`` attributes, which are used as
3+
caches.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp