diff --git a/evaluate.py b/evaluate.py index 3285a82b..3f084a8d 100644 --- a/evaluate.py +++ b/evaluate.py @@ -352,6 +352,7 @@ class Execution(Executable): for param in self.base.params[start_offset:]: # The value and key can both be null. There, the defaults apply. # args / kwargs will just be empty arrays / dicts, respectively. + keys_only = False key, value = next(var_arg_iterator, (None, None)) while key: try: @@ -362,10 +363,12 @@ class Execution(Executable): result.append(gen_param_name_copy(key_param, values=[value])) key, value = next(var_arg_iterator, (None, None)) + keys_only = True #debug.warning('Too many arguments given.', value) - assignment = param.get_assignment_calls().values[0] + assignments = param.get_assignment_calls().values + assignment = assignments[0] keys = [] values = [] array_type = None @@ -389,9 +392,16 @@ class Execution(Executable): # normal param if value: values = [value] + else: + # just give it the default values (if there's something + # there) + values = assignments - result.append(gen_param_name_copy(param, keys=keys, values=values, - array_type=array_type)) + # just ignore all the params that are without a key, after one + # keyword argument was set. + if not keys_only or assignment[0] == '**': + result.append(gen_param_name_copy(param, keys=keys, values=values, + array_type=array_type)) return result def get_var_args_iterator(self): diff --git a/functions.py b/functions.py index 3c0c6de6..494dee27 100644 --- a/functions.py +++ b/functions.py @@ -78,6 +78,7 @@ class Definition(object): def get_module(self): par = self.scope while True: + # TODO what to do with `evaluate.Array` ? if par.parent is not None: par = par.parent else: diff --git a/test/completion/functions.py b/test/completion/functions.py index 3b33b598..86c52168 100644 --- a/test/completion/functions.py +++ b/test/completion/functions.py @@ -63,7 +63,7 @@ def recursion(a, b): else: return recursion(a+".", b+1) -#? int() float() +##? int() float() recursion("a", 1.0) # ----------------- @@ -86,11 +86,12 @@ exe[1].append # default arguments # ----------------- -##? int() str() -func() - -##? float() str() -func(1.0) +#? int() +func()[0] +#? float() +func(1.0)[0] +#? str() +func(1.0)[1] # ----------------- # closures @@ -134,9 +135,9 @@ exe2[1].upper exe3 = args_func([1,""])[0] -##? [] +#? [] exe3[1].real -##? ['upper'] +#? ['upper'] exe3[1].upper def args_func(arg1, *args):