From b5719649395324c8b0506de10986fe9eb4fd541b Mon Sep 17 00:00:00 2001 From: David Halter Date: Fri, 30 Nov 2012 18:00:48 +0100 Subject: [PATCH] param arguments that are being forgotten by the user are now added (no strange behaviour anymore) --- jedi/evaluate.py | 11 ++++++++++- test/completion/functions.py | 3 --- test/completion/ordering.py | 7 +++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/jedi/evaluate.py b/jedi/evaluate.py index 3028724a..ca80b4b7 100644 --- a/jedi/evaluate.py +++ b/jedi/evaluate.py @@ -600,6 +600,7 @@ class Execution(Executable): var_arg_iterator = self.get_var_args_iterator() non_matching_keys = [] + keys_used = set() keys_only = False for param in self.base.params[start_offset:]: # The value and key can both be null. There, the defaults apply. @@ -609,15 +610,16 @@ class Execution(Executable): # completions. key, value = next(var_arg_iterator, (None, None)) while key: + keys_only = True try: key_param = param_dict[str(key)] except KeyError: non_matching_keys.append((key, value)) else: + keys_used.add(str(key)) result.append(gen_param_name_copy(key_param, values=[value])) key, value = next(var_arg_iterator, (None, None)) - keys_only = True assignments = param.get_assignment_calls().values assignment = assignments[0] @@ -657,8 +659,15 @@ class Execution(Executable): # Just ignore all the params that are without a key, after one # keyword argument was set. if not keys_only or assignment[0] == '**': + keys_used.add(str(key)) result.append(gen_param_name_copy(param, keys=keys, values=values, array_type=array_type)) + + if keys_only: + # sometimes param arguments are not completely written (which would + # create an Exception, but we have to handle that). + for k in set(param_dict) - keys_used: + result.append(gen_param_name_copy(param_dict[k])) return result def get_var_args_iterator(self): diff --git a/test/completion/functions.py b/test/completion/functions.py index 26233521..2d9a4512 100644 --- a/test/completion/functions.py +++ b/test/completion/functions.py @@ -90,9 +90,6 @@ recursion2(1) # ordering # ----------------- -#def b(): - #return "" - def a(): #? int() b() diff --git a/test/completion/ordering.py b/test/completion/ordering.py index 994ec8a8..f34c5229 100644 --- a/test/completion/ordering.py +++ b/test/completion/ordering.py @@ -82,6 +82,13 @@ def func(a_param): a_param. from os import path + + +# should not return a function, because `a` is a function above +def f(b, a): return a +#? [] +f(b=3) + # ----------------- # class # -----------------