summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na@python.org>2021-10-16 15:12:58 (GMT)
committerGitHub <noreply@github.com>2021-10-16 15:12:58 (GMT)
commit15ad52fbf607b6ccec44a38a8a32a5f1fad635ee (patch)
tree242594a0688416f2176373afd1bcee36795e2889 /Lib/typing.py
parent4ecd119b007cb766b8bede2dc78b70d29cd932dd (diff)
downloadcpython-15ad52fbf607b6ccec44a38a8a32a5f1fad635ee.zip
cpython-15ad52fbf607b6ccec44a38a8a32a5f1fad635ee.tar.gz
cpython-15ad52fbf607b6ccec44a38a8a32a5f1fad635ee.tar.bz2
bpo-45489: Update ForwardRef to support | operator. (GH-28991)
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index ada9adb..78d973d 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -719,6 +719,12 @@ class ForwardRef(_Final, _root=True):
def __hash__(self):
return hash(self.__forward_arg__)
+ def __or__(self, other):
+ return Union[self, other]
+
+ def __ror__(self, other):
+ return Union[other, self]
+
def __repr__(self):
return f'ForwardRef({self.__forward_arg__!r})'