Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Lib/annotationlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ def __eq__(self, other):
# because dictionaries are not hashable.
and self.__globals__ is other.__globals__
and self.__forward_is_class__ == other.__forward_is_class__
and self.__code__ == other.__code__
and self.__ast_node__ == other.__ast_node__
and self.__cell__ == other.__cell__
and self.__owner__ == other.__owner__
)
Expand All @@ -237,8 +235,6 @@ def __hash__(self):
self.__forward_module__,
id(self.__globals__), # dictionaries are not hashable, so hash by identity
self.__forward_is_class__,
self.__code__,
self.__ast_node__,
self.__cell__,
self.__owner__,
))
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6529,6 +6529,13 @@ def test_or(self):
self.assertEqual(X | "x", Union[X, "x"])
self.assertEqual("x" | X, Union["x", X])

def test_multiple_ways_to_create(self):
X1 = Union["X"]
self.assertIsInstance(X1, ForwardRef)
X2 = ForwardRef("X")
self.assertIsInstance(X2, ForwardRef)
self.assertEqual(X1, X2)


class InternalsTests(BaseTestCase):
def test_deprecation_for_no_type_params_passed_to__evaluate(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Comparison of :class:`annotationlib.ForwardRef` objects no longer uses the
internal ``__code__`` and ``__ast_node__`` attributes, which are used as
caches.
Loading