diff options
author | Martin Rueckl <enigma@nbubu.de> | 2021-10-27 21:36:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-27 21:36:41 (GMT) |
commit | d02ffd1b5c0fd8dec6dd2f7e3f2b0cfae48b7899 (patch) | |
tree | 22f2b94683fb57ccb1336efed4084858cdcd8f74 /Lib/inspect.py | |
parent | 10bbd41ba8c88bc102df108a4e0444abc7c5ea43 (diff) | |
download | cpython-d02ffd1b5c0fd8dec6dd2f7e3f2b0cfae48b7899.zip cpython-d02ffd1b5c0fd8dec6dd2f7e3f2b0cfae48b7899.tar.gz cpython-d02ffd1b5c0fd8dec6dd2f7e3f2b0cfae48b7899.tar.bz2 |
bpo-45438: format of inspect.Signature with generic builtins (#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>
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index a956acf..14a42fd 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -1325,6 +1325,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__ |