MCPcopy Index your code
hub / github.com/RustPython/RustPython / _signature_bound_method

Function _signature_bound_method

Lib/inspect.py:2031–2054  ·  view source on GitHub ↗

Private helper to transform signatures for unbound functions to bound methods.

(sig)

Source from the content-addressed store, hash-verified

2029
2030
2031def _signature_bound_method(sig):
2032 """Private helper to transform signatures for unbound
2033 functions to bound methods.
2034 """
2035
2036 params = tuple(sig.parameters.values())
2037
2038 if not params or params[0].kind in (_VAR_KEYWORD, _KEYWORD_ONLY):
2039 raise ValueError('invalid method signature')
2040
2041 kind = params[0].kind
2042 if kind in (_POSITIONAL_OR_KEYWORD, _POSITIONAL_ONLY):
2043 # Drop first parameter:
2044 # '(p1, p2[, ...])' -> '(p2[, ...])'
2045 params = params[1:]
2046 else:
2047 if kind is not _VAR_POSITIONAL:
2048 # Unless we add a new parameter type we never
2049 # get here
2050 raise ValueError('invalid argument type')
2051 # It's a var-positional parameter.
2052 # Do nothing. '(*args[, ...])' -> '(*args[, ...])'
2053
2054 return sig.replace(parameters=params)
2055
2056
2057def _signature_is_builtin(obj):

Callers 1

_signature_from_callableFunction · 0.85

Calls 2

valuesMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected