Skip to content

Commit b3e3cc0

Browse files
authored
Remove deferred typing import in annotationlib (#132034)
1 parent 6bd9689 commit b3e3cc0

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

Lib/annotationlib.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class Format(enum.IntEnum):
2727
STRING = 4
2828

2929

30-
_Union = None
3130
_sentinel = object()
3231

3332
# Slots shared by ForwardRef and _Stringifier. The __forward__ names must be
@@ -246,16 +245,10 @@ def __hash__(self):
246245
return hash((self.__forward_arg__, self.__forward_module__))
247246

248247
def __or__(self, other):
249-
global _Union
250-
if _Union is None:
251-
from typing import Union as _Union
252-
return _Union[self, other]
248+
return types.UnionType[self, other]
253249

254250
def __ror__(self, other):
255-
global _Union
256-
if _Union is None:
257-
from typing import Union as _Union
258-
return _Union[other, self]
251+
return types.UnionType[other, self]
259252

260253
def __repr__(self):
261254
if self.__forward_module__ is None:

0 commit comments

Comments
 (0)