https://github.com/python/cpython/commit/b3e3cc054c2c7718c0ad7c4690f76716649a2588
commit: b3e3cc054c2c7718c0ad7c4690f76716649a2588
branch: main
author: Adam Turner <9087854+aa-tur...@users.noreply.github.com>
committer: JelleZijlstra <jelle.zijls...@gmail.com>
date: 2025-04-02T20:30:31-07:00
summary:

Remove deferred ``typing`` import in ``annotationlib`` (#132034)

files:
M Lib/annotationlib.py

diff --git a/Lib/annotationlib.py b/Lib/annotationlib.py
index 42f1f3877514d9..c08cd4d66589b6 100644
--- a/Lib/annotationlib.py
+++ b/Lib/annotationlib.py
@@ -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 @@ def __hash__(self):
         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:

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to