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

Function _signature_get_user_defined_method

Lib/inspect.py:1910–1937  ·  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

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

Callers 1

_signature_from_callableFunction · 0.85

Calls 7

getattrFunction · 0.85
getattr_staticFunction · 0.85
hasattrFunction · 0.85
_signature_is_builtinFunction · 0.85
isinstanceFunction · 0.85
_descriptor_getFunction · 0.85
unwrapFunction · 0.70

Tested by

no test coverage detected