MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _signature_bound_method

Function _signature_bound_method

tools/python-3.11.9-amd64/Lib/inspect.py:2037–2060  ·  view source on GitHub ↗

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

(sig)

Source from the content-addressed store, hash-verified

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

Callers 1

_signature_from_callableFunction · 0.85

Calls 3

tupleClass · 0.85
valuesMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected