mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705)
This commit is contained in:
parent
96aeaec647
commit
d53cf99dca
17 changed files with 40 additions and 3 deletions
|
@ -3782,6 +3782,17 @@ class TestSignatureDefinitions(unittest.TestCase):
|
|||
with self.subTest(builtin=name):
|
||||
self.assertIsNone(obj.__text_signature__)
|
||||
|
||||
def test_python_function_override_signature(self):
|
||||
def func(*args, **kwargs):
|
||||
pass
|
||||
func.__text_signature__ = '($self, a, b=1, *args, c, d=2, **kwargs)'
|
||||
sig = inspect.signature(func)
|
||||
self.assertIsNotNone(sig)
|
||||
self.assertEqual(str(sig), '(self, /, a, b=1, *args, c, d=2, **kwargs)')
|
||||
func.__text_signature__ = '($self, a, b=1, /, *args, c, d=2, **kwargs)'
|
||||
sig = inspect.signature(func)
|
||||
self.assertEqual(str(sig), '(self, a, b=1, /, *args, c, d=2, **kwargs)')
|
||||
|
||||
|
||||
class NTimesUnwrappable:
|
||||
def __init__(self, n):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue