summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-10-27 21:57:07 (GMT)
committerGitHub <noreply@github.com>2021-10-27 21:57:07 (GMT)
commitce7a6afb797d2ffde45e9e902516b8437c8f9e31 (patch)
tree1c66d8bd766f45dc5ec20996aef8083ee4b42aec /Lib/inspect.py
parent038f45230892235e806ef227dfd9484b95687823 (diff)
downloadcpython-ce7a6afb797d2ffde45e9e902516b8437c8f9e31.zip
cpython-ce7a6afb797d2ffde45e9e902516b8437c8f9e31.tar.gz
cpython-ce7a6afb797d2ffde45e9e902516b8437c8f9e31.tar.bz2
bpo-45438: format of inspect.Signature with generic builtins (GH-29212)
Use types.GenericAlias in inspect.formatannotation to correctly add type arguments of builtin types to the string representation of Signatures. Co-authored-by: Martin Rückl <martin.rueckl@codecentric.de> (cherry picked from commit d02ffd1b5c0fd8dec6dd2f7e3f2b0cfae48b7899) Co-authored-by: Martin Rueckl <enigma@nbubu.de>
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 2374e59..531b891 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1357,6 +1357,8 @@ def getargvalues(frame):
def formatannotation(annotation, base_module=None):
if getattr(annotation, '__module__', None) == 'typing':
return repr(annotation).replace('typing.', '')
+ if isinstance(annotation, types.GenericAlias):
+ return str(annotation)
if isinstance(annotation, type):
if annotation.__module__ in ('builtins', base_module):
return annotation.__qualname__