Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove call_tip function and test case for that #10104

Merged
merged 1 commit into from Dec 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 5 additions & 23 deletions IPython/core/oinspect.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
59 changes: 0 additions & 59 deletions IPython/core/tests/test_oinspect.py
Expand Up @@ -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)', '<no docstring>')


@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')
Expand Down