diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-07-24 19:35:33 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-24 19:35:33 (GMT) |
| commit | 0aea99e44416f37c75e5540072156dbf90ef1659 (patch) | |
| tree | b215881193d0032fe25dc531372f3c992902b201 /Lib/typing.py | |
| parent | ca5a4cf8266cf789eae379fe224458e94dd41b30 (diff) | |
| download | cpython-0aea99e44416f37c75e5540072156dbf90ef1659.zip cpython-0aea99e44416f37c75e5540072156dbf90ef1659.tar.gz cpython-0aea99e44416f37c75e5540072156dbf90ef1659.tar.bz2 | |
bpo-44676: Serialize the union type using only public API (GH-27323) (GH-27340)
Remove also the _from_args() constructor.
(cherry picked from commit 435a0334d341e5f8faed594d9f015746bb7845db)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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 0570b4e..ae31589 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -321,7 +321,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 @@ -1806,7 +1806,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 |
