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

Function _signature_get_user_defined_method

Lib/inspect.py:1917–1944  ·  view source on GitHub ↗

Private helper. Checks if ``cls`` has an attribute named ``method_name`` and returns it only if it is a pure python function.

(cls, method_name, *, follow_wrapper_chains=True)

Source from the content-addressed store, hash-verified

1915
1916
1917def _signature_get_user_defined_method(cls, method_name, *, follow_wrapper_chains=True):
1918 """Private helper. Checks if ``cls`` has an attribute
1919 named ``method_name`` and returns it only if it is a
1920 pure python function.
1921 """
1922 if method_name == '__new__':
1923 meth = getattr(cls, method_name, None)
1924 else:
1925 meth = getattr_static(cls, method_name, None)
1926 if meth is None:
1927 return None
1928
1929 # NOTE: The meth may wraps a non-user-defined callable.
1930 # In this case, we treat the meth as non-user-defined callable too.
1931 # (e.g. cls.__new__ generated by @warnings.deprecated)
1932 unwrapped_meth = None
1933 if follow_wrapper_chains:
1934 unwrapped_meth = unwrap(meth, stop=(lambda m: hasattr(m, "__signature__")
1935 or _signature_is_builtin(m)))
1936
1937 if (isinstance(meth, _NonUserDefinedCallables)
1938 or isinstance(unwrapped_meth, _NonUserDefinedCallables)):
1939 # Once '__signature__' will be added to 'C'-level
1940 # callables, this check won't be necessary
1941 return None
1942 if method_name != '__new__':
1943 meth = _descriptor_get(meth, cls)
1944 return meth
1945
1946
1947def _signature_get_partial(wrapped_sig, partial, extra_args=()):

Callers 1

_signature_from_callableFunction · 0.85

Calls 4

getattr_staticFunction · 0.85
_signature_is_builtinFunction · 0.85
_descriptor_getFunction · 0.85
unwrapFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…