Skip to content

Commit e719e23

Browse files
Fix annotationlib.
1 parent 5cd4a72 commit e719e23

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Lib/annotationlib.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,12 @@ def __hash__(self):
284284
))
285285

286286
def __or__(self, other):
287-
return types.UnionType[self, other]
287+
import typing
288+
return typing.Union[self, other]
288289

289290
def __ror__(self, other):
290-
return types.UnionType[other, self]
291+
import typing
292+
return typing.Union[other, self]
291293

292294
def __repr__(self):
293295
extra = []

Lib/test/test_annotationlib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ class UnionForwardrefs:
137137
str | int,
138138
)
139139
union = annos["union"]
140-
self.assertIsInstance(union, Union)
140+
self.assertIs(typing.get_origin(union), Union)
141+
# self.assertIsInstance(union, Union)
141142
arg1, arg2 = typing.get_args(union)
142143
self.assertIs(arg1, str)
143144
self.assertEqual(

0 commit comments

Comments
 (0)