summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-04-27 07:27:21 (GMT)
committerGitHub <noreply@github.com>2020-04-27 07:27:21 (GMT)
commit6292be7adf247589bbf03524f8883cb4cb61f3e9 (patch)
tree491a02064847cb3158bd029e178486b42bbc23e7 /Lib/typing.py
parentcaf1aadf3d020f742ba3d7fcf678ca700224914b (diff)
downloadcpython-6292be7adf247589bbf03524f8883cb4cb61f3e9.zip
cpython-6292be7adf247589bbf03524f8883cb4cb61f3e9.tar.gz
cpython-6292be7adf247589bbf03524f8883cb4cb61f3e9.tar.bz2
bpo-40398: Fix typing.get_args() for special generic aliases. (GH-19720)
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 1aefcb8..c829898 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1420,11 +1420,13 @@ def get_args(tp):
"""
if isinstance(tp, _AnnotatedAlias):
return (tp.__origin__,) + tp.__metadata__
- if isinstance(tp, (_GenericAlias, GenericAlias)):
+ if isinstance(tp, _GenericAlias) and not tp._special:
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 ()