diff options
author | Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> | 2020-12-28 20:06:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-28 20:06:19 (GMT) |
commit | 4140f10a16f06c32fd49f9e21fb2a53abe7357f0 (patch) | |
tree | ec6e4a38d4d03b786196e86592b663a78b774493 /Lib/typing.py | |
parent | a9621bb301dba44494e81edc00e3a3b62c96af26 (diff) | |
download | cpython-4140f10a16f06c32fd49f9e21fb2a53abe7357f0.zip cpython-4140f10a16f06c32fd49f9e21fb2a53abe7357f0.tar.gz cpython-4140f10a16f06c32fd49f9e21fb2a53abe7357f0.tar.bz2 |
bpo-42740: Fix get_args for PEP 585 collections.abc.Callable (GH-23963)
PR 1/2. Needs backport to 3.9.
Diffstat (limited to 'Lib/typing.py')
-rw-r--r-- | Lib/typing.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/Lib/typing.py b/Lib/typing.py index 7b79876..67e95dd 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1684,13 +1684,11 @@ def get_args(tp): """ if isinstance(tp, _AnnotatedAlias): return (tp.__origin__,) + tp.__metadata__ - if isinstance(tp, _GenericAlias): + if isinstance(tp, (_GenericAlias, GenericAlias)): res = tp.__args__ if tp.__origin__ is collections.abc.Callable and res[0] is not Ellipsis: res = (list(res[:-1]), res[-1]) return res - if isinstance(tp, GenericAlias): - return tp.__args__ return () |