summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-07-24 18:26:02 (GMT)
committerGitHub <noreply@github.com>2021-07-24 18:26:02 (GMT)
commit435a0334d341e5f8faed594d9f015746bb7845db (patch)
tree5c090299361ae9dabe002f2936044a01b1022b16 /Lib/typing.py
parent4f5980a4f57dab68b9137304f58bd08891d43d5a (diff)
downloadcpython-435a0334d341e5f8faed594d9f015746bb7845db.zip
cpython-435a0334d341e5f8faed594d9f015746bb7845db.tar.gz
cpython-435a0334d341e5f8faed594d9f015746bb7845db.tar.bz2
bpo-44676: Serialize the union type using only public API (GH-27323)
Remove also the _from_args() constructor.
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 3403f55..844cf97 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -329,7 +329,7 @@ def _eval_type(t, globalns, localns, recursive_guard=frozenset()):
if isinstance(t, GenericAlias):
return GenericAlias(t.__origin__, ev_args)
if isinstance(t, types.Union):
- return types.Union._from_args(ev_args)
+ return functools.reduce(operator.or_, ev_args)
else:
return t.copy_with(ev_args)
return t
@@ -1814,7 +1814,7 @@ def _strip_annotations(t):
stripped_args = tuple(_strip_annotations(a) for a in t.__args__)
if stripped_args == t.__args__:
return t
- return types.Union._from_args(stripped_args)
+ return functools.reduce(operator.or_, stripped_args)
return t