Skip to content

Commit

Permalink
MNT: use back-ported signature on py2
Browse files Browse the repository at this point in the history
  • Loading branch information
tacaswell committed Sep 8, 2015
1 parent 2ad3e25 commit 26717c3
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions IPython/core/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,21 +843,22 @@ def _default_arguments(self, obj):
getattr(call_obj, '__doc__', ''))

if PY3:
_keepers = (inspect.Parameter.KEYWORD_ONLY,
inspect.Parameter.POSITIONAL_OR_KEYWORD)
try:
sig = inspect.signature(call_obj)
ret.extend(k for k, v in sig.parameters.items() if
v.kind in _keepers)
except ValueError:
pass
_keeps = (inspect.Parameter.KEYWORD_ONLY,
inspect.Parameter.POSITIONAL_OR_KEYWORD)
signature = inspect.signature
else:
try:
args, _, _1, defaults = inspect.getargspec(call_obj)
if defaults:
ret += args[-len(defaults):]
except TypeError:
pass
import IPython.utils.signature
_keeps = (IPython.utils.signature.Parameter.KEYWORD_ONLY,
IPython.utils.signature.Parameter.POSITIONAL_OR_KEYWORD)
signature = IPython.utils.signature.signature

try:
sig = signature(call_obj)
ret.extend(k for k, v in sig.parameters.items() if
v.kind in _keeps)
except ValueError:
pass

return list(set(ret))

def python_func_kw_matches(self,text):
Expand Down

0 comments on commit 26717c3

Please sign in to comment.