(isinstance(annotations, (dict)) or annotations is None) )
-def _signature_get_bound_param(spec):
- """ Private helper to get first parameter name from a
- __text_signature__ of a builtin method, which should
- be in the following format: '($param1, ...)'.
- Assumptions are that the first argument won't have
- a default value or an annotation.
- """
-
- assert spec.startswith('($')
-
- pos = spec.find(',')
- if pos == -1:
- pos = spec.find(')')
-
- cpos = spec.find(':')
- assert cpos == -1 or cpos > pos
-
- cpos = spec.find('=')
- assert cpos == -1 or cpos > pos
-
- return spec[2:pos]
-
-
def _signature_strip_non_python_syntax(signature):
"""
Private helper function. Takes a signature in Argument Clinic's
self.assertIs(type(ba.arguments), dict)
class TestSignaturePrivateHelpers(unittest.TestCase):
- def test_signature_get_bound_param(self):
- getter = inspect._signature_get_bound_param
-
- self.assertEqual(getter('($self)'), 'self')
- self.assertEqual(getter('($self, obj)'), 'self')
- self.assertEqual(getter('($cls, /, obj)'), 'cls')
-
def _strip_non_python_syntax(self, input,
clean_signature, self_parameter, last_positional_only):
computed_clean_signature, \