1# encoding: utf-8
2"""Generic functions for extending IPython."""
3
4from __future__ import annotations
5
6from typing import Any
7
8from IPython.core.error import TryNext
9from functools import singledispatch
10
11
12@singledispatch
13def inspect_object(obj: Any) -> None:
14 """Called when you do obj?"""
15 raise TryNext
16
17
18@singledispatch
19def complete_object(obj: Any, prev_completions: list[str]) -> list[str]:
20 """Custom completer dispatching for python objects.
21
22 Parameters
23 ----------
24 obj : object
25 The object to complete.
26 prev_completions : list
27 List of attributes discovered so far.
28 This should return the list of attributes in obj. If you only wish to
29 add to the attributes already discovered normally, return
30 own_attrs + prev_completions.
31 """
32 raise TryNext