##// END OF EJS Templates
Merge pull request #6932 from takluyver/help-signatures...
Thomas Kluyver -
r18873:cf19c83f merge
parent child Browse files
Show More
@@ -40,6 +40,7 b' from IPython.utils.text import indent'
40 40 from IPython.utils.wildcard import list_namespace
41 41 from IPython.utils.coloransi import TermColors, ColorScheme, ColorSchemeTable
42 42 from IPython.utils.py3compat import cast_unicode, string_types, PY3
43 from IPython.utils.signatures import signature
43 44
44 45 # builtin docstrings to ignore
45 46 _func_call_docstring = types.FunctionType.__call__.__doc__
@@ -390,7 +391,7 b' class Inspector:'
390 391 If any exception is generated, None is returned instead and the
391 392 exception is suppressed."""
392 393 try:
393 hdef = oname + inspect.formatargspec(*getargspec(obj))
394 hdef = oname + str(signature(obj))
394 395 return cast_unicode(hdef)
395 396 except:
396 397 return None
@@ -72,10 +72,13 b' def signature(obj):'
72 72 raise TypeError('{0!r} is not a callable object'.format(obj))
73 73
74 74 if isinstance(obj, types.MethodType):
75 # In this case we skip the first parameter of the underlying
76 # function (usually `self` or `cls`).
77 sig = signature(obj.__func__)
78 return sig.replace(parameters=tuple(sig.parameters.values())[1:])
75 if obj.__self__ is None:
76 # Unbound method - treat it as a function (no distinction in Py 3)
77 obj = obj.__func__
78 else:
79 # Bound method: trim off the first parameter (typically self or cls)
80 sig = signature(obj.__func__)
81 return sig.replace(parameters=tuple(sig.parameters.values())[1:])
79 82
80 83 try:
81 84 sig = obj.__signature__
General Comments 0
You need to be logged in to leave comments. Login now