##// END OF EJS Templates
Merge pull request #11419 from elyashiv/fix-tab-kw-args...
Matthias Bussonnier -
r24768:5a8f4071 merge
parent child Browse files
Show More
@@ -1538,24 +1538,19 b' class IPCompleter(Completer):'
1538
1538
1539 usedNamedArgs.add(token)
1539 usedNamedArgs.add(token)
1540
1540
1541 # lookup the candidate callable matches either using global_matches
1542 # or attr_matches for dotted names
1543 if len(ids) == 1:
1544 callableMatches = self.global_matches(ids[0])
1545 else:
1546 callableMatches = self.attr_matches('.'.join(ids[::-1]))
1547 argMatches = []
1541 argMatches = []
1548 for callableMatch in callableMatches:
1542 try:
1549 try:
1543 callableObj = '.'.join(ids[::-1])
1550 namedArgs = self._default_arguments(eval(callableMatch,
1544 namedArgs = self._default_arguments(eval(callableObj,
1551 self.namespace))
1545 self.namespace))
1552 except:
1553 continue
1554
1546
1555 # Remove used named arguments from the list, no need to show twice
1547 # Remove used named arguments from the list, no need to show twice
1556 for namedArg in set(namedArgs) - usedNamedArgs:
1548 for namedArg in set(namedArgs) - usedNamedArgs:
1557 if namedArg.startswith(text):
1549 if namedArg.startswith(text):
1558 argMatches.append(u"%s=" %namedArg)
1550 argMatches.append(u"%s=" %namedArg)
1551 except:
1552 pass
1553
1559 return argMatches
1554 return argMatches
1560
1555
1561 def dict_key_matches(self, text):
1556 def dict_key_matches(self, text):
@@ -1027,3 +1027,23 b' def test_snake_case_completion():'
1027 _, matches = ip.complete("s_", "print(s_f")
1027 _, matches = ip.complete("s_", "print(s_f")
1028 nt.assert_in('some_three', matches)
1028 nt.assert_in('some_three', matches)
1029 nt.assert_in('some_four', matches)
1029 nt.assert_in('some_four', matches)
1030
1031 def test_mix_terms():
1032 ip = get_ipython()
1033 from textwrap import dedent
1034 ip.Completer.use_jedi = False
1035 ip.ex(dedent("""
1036 class Test:
1037 def meth(self, meth_arg1):
1038 print("meth")
1039
1040 def meth_1(self, meth1_arg1, meth1_arg2):
1041 print("meth1")
1042
1043 def meth_2(self, meth2_arg1, meth2_arg2):
1044 print("meth2")
1045 test = Test()
1046 """))
1047 _, matches = ip.complete(None, "test.meth(")
1048 nt.assert_in('meth_arg1=', matches)
1049 nt.assert_not_in('meth2_arg1=', matches)
General Comments 0
You need to be logged in to leave comments. Login now