diff --git a/IPython/core/oinspect.py b/IPython/core/oinspect.py index 7f273a5ca0b..7934e5e9398 100644 --- a/IPython/core/oinspect.py +++ b/IPython/core/oinspect.py @@ -41,6 +41,7 @@ from IPython.utils.coloransi import TermColors, ColorScheme, ColorSchemeTable from IPython.utils.py3compat import cast_unicode, string_types, PY3 from IPython.utils.colorable import Colorable +from IPython.utils.decorators import undoc from pygments import highlight from pygments.lexers import PythonLexer @@ -231,31 +232,12 @@ def format_argspec(argspec): return inspect.formatargspec(argspec['args'], argspec['varargs'], argspec['varkw'], argspec['defaults']) - +@undoc def call_tip(oinfo, format_call=True): - """Extract call tip data from an oinfo dict. - - Parameters - ---------- - oinfo : dict - - format_call : bool, optional - If True, the call line is formatted and returned as a string. If not, a - tuple of (name, argspec) is returned. - - Returns - ------- - call_info : None, str or (str, dict) tuple. - When format_call is True, the whole call information is formattted as a - single string. Otherwise, the object's name and its argspec dict are - returned. If no call information is available, None is returned. - - docstring : str or None - The most relevant docstring for calling purposes is returned, if - available. The priority is: call docstring for callable instances, then - constructor docstring for classes, then main object's docstring otherwise - (regular functions). + """DEPRECATED. Extract call tip data from an oinfo dict. """ + warnings.warn('`call_tip` function is deprecated as of IPython 5.2 ' + 'and will have no effects.', DeprecationWarning, stacklevel=2) # Get call definition argspec = oinfo.get('argspec') if argspec is None: diff --git a/IPython/core/tests/test_oinspect.py b/IPython/core/tests/test_oinspect.py index 534f5d72045..04b59acbb2a 100644 --- a/IPython/core/tests/test_oinspect.py +++ b/IPython/core/tests/test_oinspect.py @@ -206,69 +206,10 @@ def __init__(self, max_fibbing_twig, lies_told=0): def __getattr__(self, item): return SerialLiar(self.max_fibbing_twig, self.lies_told + 1) - -def check_calltip(obj, name, call, docstring): - """Generic check pattern all calltip tests will use""" - info = inspector.info(obj, name) - call_line, ds = oinspect.call_tip(info) - nt.assert_equal(call_line, call) - nt.assert_equal(ds, docstring) - #----------------------------------------------------------------------------- # Tests #----------------------------------------------------------------------------- -def test_calltip_class(): - check_calltip(Call, 'Call', 'Call(x, y=1)', Call.__init__.__doc__) - - -def test_calltip_instance(): - c = Call(1) - check_calltip(c, 'c', 'c(*a, **kw)', c.__call__.__doc__) - - -def test_calltip_method(): - c = Call(1) - check_calltip(c.method, 'c.method', 'c.method(x, z=2)', c.method.__doc__) - - -def test_calltip_function(): - check_calltip(f, 'f', 'f(x, y=2, *a, **kw)', f.__doc__) - - -def test_calltip_function2(): - check_calltip(g, 'g', 'g(y, z=3, *a, **kw)', '') - - -@skipif(sys.version_info >= (3, 5)) -def test_calltip_builtin(): - check_calltip(sum, 'sum', None, sum.__doc__) - - -def test_calltip_line_magic(): - check_calltip(lmagic, 'lmagic', 'lmagic(line)', "A line magic") - - -def test_calltip_cell_magic(): - check_calltip(cmagic, 'cmagic', 'cmagic(line, cell)', "A cell magic") - - -def test_calltip_line_cell_magic(): - check_calltip(lcmagic, 'lcmagic', 'lcmagic(line, cell=None)', - "A line/cell magic") - - -def test_class_magics(): - cm = SimpleMagics(ip) - ip.register_magics(cm) - check_calltip(cm.Clmagic, 'Clmagic', 'Clmagic(cline)', - "A class-based line magic") - check_calltip(cm.Ccmagic, 'Ccmagic', 'Ccmagic(cline, ccell)', - "A class-based cell magic") - check_calltip(cm.Clcmagic, 'Clcmagic', 'Clcmagic(cline, ccell=None)', - "A class-based line/cell magic") - - def test_info(): "Check that Inspector.info fills out various fields as expected." i = inspector.info(Call, oname='Call')