MCPcopy Index your code
hub / github.com/ipython/ipython / _default_arguments

Method _default_arguments

IPython/core/completer.py:2867–2899  ·  view source on GitHub ↗

Return the list of default arguments of obj if it is callable, or empty list otherwise.

(self, obj)

Source from the content-addressed store, hash-verified

2865 return ret
2866
2867 def _default_arguments(self, obj):
2868 """Return the list of default arguments of obj if it is callable,
2869 or empty list otherwise."""
2870 call_obj = obj
2871 ret = []
2872 if inspect.isbuiltin(obj):
2873 pass
2874 elif not (inspect.isfunction(obj) or inspect.ismethod(obj)):
2875 if inspect.isclass(obj):
2876 #for cython embedsignature=True the constructor docstring
2877 #belongs to the object itself not __init__
2878 ret += self._default_arguments_from_docstring(
2879 getattr(obj, '__doc__', ''))
2880 # for classes, check for __init__,__new__
2881 call_obj = (getattr(obj, '__init__', None) or
2882 getattr(obj, '__new__', None))
2883 # for all others, check if they are __call__able
2884 elif hasattr(obj, '__call__'):
2885 call_obj = obj.__call__
2886 ret += self._default_arguments_from_docstring(
2887 getattr(call_obj, '__doc__', ''))
2888
2889 _keeps = (inspect.Parameter.KEYWORD_ONLY,
2890 inspect.Parameter.POSITIONAL_OR_KEYWORD)
2891
2892 try:
2893 sig = inspect.signature(obj)
2894 ret.extend(k for k, v in sig.parameters.items() if
2895 v.kind in _keeps)
2896 except ValueError:
2897 pass
2898
2899 return list(set(ret))
2900
2901 @context_matcher()
2902 def python_func_kw_matcher(self, context: CompletionContext) -> SimpleMatcherResult:

Callers 1

Tested by

no test coverage detected