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

Method _get_keys

IPython/core/completer.py:2990–3011  ·  view source on GitHub ↗
(obj: Any)

Source from the content-addressed store, hash-verified

2988
2989 @staticmethod
2990 def _get_keys(obj: Any) -> list[Any]:
2991 # Objects can define their own completions by defining an
2992 # _ipy_key_completions_() method.
2993 method = get_real_method(obj, '_ipython_key_completions_')
2994 if method is not None:
2995 return method()
2996
2997 # Special case some common in-memory dict-like types
2998 if isinstance(obj, dict) or _safe_isinstance(obj, "pandas", "DataFrame"):
2999 try:
3000 return list(obj.keys())
3001 except Exception:
3002 return []
3003 elif _safe_isinstance(obj, "pandas", "core", "indexing", "_LocIndexer"):
3004 try:
3005 return list(obj.obj.keys())
3006 except Exception:
3007 return []
3008 elif _safe_isinstance(obj, 'numpy', 'ndarray') or\
3009 _safe_isinstance(obj, 'numpy', 'void'):
3010 return obj.dtype.names or []
3011 return []
3012
3013 @context_matcher()
3014 def dict_key_matcher(self, context: CompletionContext) -> SimpleMatcherResult:

Callers 1

dict_key_matchesMethod · 0.95

Calls 3

get_real_methodFunction · 0.90
_safe_isinstanceFunction · 0.85
keysMethod · 0.80

Tested by

no test coverage detected