diff options
author | Yurii Karabas <1998uriyyo@gmail.com> | 2021-07-23 09:47:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-23 09:47:00 (GMT) |
commit | fe13f0b0f696464dd6f283576668dbf57cb11399 (patch) | |
tree | f6ef8c05220fc75cf20cb7eb9e7e2375c0db3ecb /Lib/typing.py | |
parent | 7d25254cf0763b62f4c4a3019e56385cab597b9f (diff) | |
download | cpython-fe13f0b0f696464dd6f283576668dbf57cb11399.zip cpython-fe13f0b0f696464dd6f283576668dbf57cb11399.tar.gz cpython-fe13f0b0f696464dd6f283576668dbf57cb11399.tar.bz2 |
bpo-44676: Add ability to serialize types.Union (GH-27244)
Diffstat (limited to 'Lib/typing.py')
-rw-r--r-- | Lib/typing.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/typing.py b/Lib/typing.py index 5c95a4d..e618513 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 functools.reduce(operator.or_, ev_args) + return types.Union._from_args(ev_args) else: return t.copy_with(ev_args) return t @@ -1808,7 +1808,7 @@ def _strip_annotations(t): stripped_args = tuple(_strip_annotations(a) for a in t.__args__) if stripped_args == t.__args__: return t - return functools.reduce(operator.or_, stripped_args) + return types.Union._from_args(stripped_args) return t |