From 5a8f40719e8dba69e1a0ff888ba5af5c6c601ed7 2018-10-25 15:51:48 From: Matthias Bussonnier Date: 2018-10-25 15:51:48 Subject: [PATCH] Merge pull request #11419 from elyashiv/fix-tab-kw-args removed expansion of function name when completing kw-args --- diff --git a/IPython/core/completer.py b/IPython/core/completer.py index 9858236..0bf7355 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -1538,24 +1538,19 @@ class IPCompleter(Completer): usedNamedArgs.add(token) - # lookup the candidate callable matches either using global_matches - # or attr_matches for dotted names - if len(ids) == 1: - callableMatches = self.global_matches(ids[0]) - else: - callableMatches = self.attr_matches('.'.join(ids[::-1])) argMatches = [] - for callableMatch in callableMatches: - try: - namedArgs = self._default_arguments(eval(callableMatch, - self.namespace)) - except: - continue + try: + callableObj = '.'.join(ids[::-1]) + namedArgs = self._default_arguments(eval(callableObj, + self.namespace)) # Remove used named arguments from the list, no need to show twice for namedArg in set(namedArgs) - usedNamedArgs: if namedArg.startswith(text): argMatches.append(u"%s=" %namedArg) + except: + pass + return argMatches def dict_key_matches(self, text): diff --git a/IPython/core/tests/test_completer.py b/IPython/core/tests/test_completer.py index 74c53ad..e6baf0e 100644 --- a/IPython/core/tests/test_completer.py +++ b/IPython/core/tests/test_completer.py @@ -1027,3 +1027,23 @@ def test_snake_case_completion(): _, matches = ip.complete("s_", "print(s_f") nt.assert_in('some_three', matches) nt.assert_in('some_four', matches) + +def test_mix_terms(): + ip = get_ipython() + from textwrap import dedent + ip.Completer.use_jedi = False + ip.ex(dedent(""" + class Test: + def meth(self, meth_arg1): + print("meth") + + def meth_1(self, meth1_arg1, meth1_arg2): + print("meth1") + + def meth_2(self, meth2_arg1, meth2_arg2): + print("meth2") + test = Test() + """)) + _, matches = ip.complete(None, "test.meth(") + nt.assert_in('meth_arg1=', matches) + nt.assert_not_in('meth2_arg1=', matches)