]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Remove deferred ``typing`` import in ``annotationlib`` (#132034)
authorAdam Turner <9087854+AA-Turner@users.noreply.github.com>
Thu, 3 Apr 2025 03:30:31 +0000 (04:30 +0100)
committerGitHub <noreply@github.com>
Thu, 3 Apr 2025 03:30:31 +0000 (20:30 -0700)
Lib/annotationlib.py

index 42f1f3877514d99d157e06b7dda23de5c157f94b..c08cd4d66589b6bde159d246b546ad470fede49b 100644 (file)
@@ -27,7 +27,6 @@ class Format(enum.IntEnum):
     STRING = 4
 
 
-_Union = None
 _sentinel = object()
 
 # Slots shared by ForwardRef and _Stringifier. The __forward__ names must be
@@ -246,16 +245,10 @@ class ForwardRef:
         return hash((self.__forward_arg__, self.__forward_module__))
 
     def __or__(self, other):
-        global _Union
-        if _Union is None:
-            from typing import Union as _Union
-        return _Union[self, other]
+        return types.UnionType[self, other]
 
     def __ror__(self, other):
-        global _Union
-        if _Union is None:
-            from typing import Union as _Union
-        return _Union[other, self]
+        return types.UnionType[other, self]
 
     def __repr__(self):
         if self.__forward_module__ is None: