mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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>
This commit is contained in:
parent
10bbd41ba8
commit
d02ffd1b5c
3 changed files with 14 additions and 0 deletions
|
@ -3236,6 +3236,17 @@ class TestSignatureObject(unittest.TestCase):
|
|||
pass
|
||||
self.assertEqual(str(inspect.signature(foo)), '()')
|
||||
|
||||
def foo(a: list[str]) -> tuple[str, float]:
|
||||
pass
|
||||
self.assertEqual(str(inspect.signature(foo)),
|
||||
'(a: list[str]) -> tuple[str, float]')
|
||||
|
||||
from typing import Tuple
|
||||
def foo(a: list[str]) -> Tuple[str, float]:
|
||||
pass
|
||||
self.assertEqual(str(inspect.signature(foo)),
|
||||
'(a: list[str]) -> Tuple[str, float]')
|
||||
|
||||
def test_signature_str_positional_only(self):
|
||||
P = inspect.Parameter
|
||||
S = inspect.Signature
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue