MCPcopy Index your code
hub / github.com/python/cpython / _signature_bound_method

Function _signature_bound_method

Lib/inspect.py:2038–2061  ·  view source on GitHub ↗

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

(sig)

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…