Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/IPython/utils/generics.py: 61%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

18 statements  

1# encoding: utf-8 

2"""Generic functions for extending IPython.""" 

3 

4from __future__ import annotations 

5 

6import warnings 

7from typing import Any 

8 

9from IPython.core.error import TryNext 

10from functools import singledispatch 

11 

12 

13@singledispatch 

14def _inspect_object(obj: Any) -> None: 

15 """Called when you do obj? 

16 

17 .. deprecated:: 9.15 

18 `inspect_object` is deprecated and will be removed in a future 

19 version. It is no longer used within IPython, so registering 

20 handlers on it has no effect. 

21 """ 

22 raise TryNext 

23 

24 

25def __getattr__(name: str) -> Any: 

26 if name == "inspect_object": 

27 warnings.warn( 

28 "inspect_object is deprecated since IPython 9.15 and will be " 

29 "removed in a future version. It is no longer used within " 

30 "IPython, so registering handlers on it has no effect.", 

31 DeprecationWarning, 

32 stacklevel=2, 

33 ) 

34 return _inspect_object 

35 raise AttributeError(f"module {__name__!r} has no attribute {name!r}") 

36 

37 

38@singledispatch 

39def complete_object(obj: Any, prev_completions: list[str]) -> list[str]: 

40 """Custom completer dispatching for python objects. 

41 

42 Parameters 

43 ---------- 

44 obj : object 

45 The object to complete. 

46 prev_completions : list 

47 List of attributes discovered so far. 

48 This should return the list of attributes in obj. If you only wish to 

49 add to the attributes already discovered normally, return 

50 own_attrs + prev_completions. 

51 """ 

52 raise TryNext