diff --git a/dynamic.py b/dynamic.py index 0a3129ab..fb365268 100644 --- a/dynamic.py +++ b/dynamic.py @@ -21,7 +21,22 @@ class ParamListener(object): def search_params(param): + """ + This is a dynamic search for params. If you try to complete a type: + >>> def func(foo): + >>> # here is the completion + >>> foo + >>> func(1) + >>> func("") + + It is not known what the type is, because it cannot be guessed with + recursive madness. Therefore one has to analyse the statements that are + calling the function, as well as analyzing the incoming params. + """ def get_params_for_module(module): + """ + Returns the values of a param, or an empty array. + """ try: possible_stmts = current_module.used_names[func_name] except KeyError: @@ -52,7 +67,8 @@ def search_params(param): arr = param.assignment_details[0][1] else: arr = param.get_assignment_calls() - param_name = str(arr[0][0].name) + offset = 1 if arr[0][0] in ['*', '**'] else 0 + param_name = str(arr[0][offset].name) current_module = param.get_parent_until() diff --git a/evaluate.py b/evaluate.py index e7bd52d5..ee1aafba 100644 --- a/evaluate.py +++ b/evaluate.py @@ -447,6 +447,7 @@ class Execution(Executable): def _get_function_returns(self, evaluate_generator): """ A normal Function execution """ + # Feed the listeners, with the params. for listener in self.base.listeners: listener.execute(self.get_params()) func = self.base.get_decorated_func() diff --git a/test/completion/dynamic.py b/test/completion/dynamic.py index 5eb9e655..1eba6266 100644 --- a/test/completion/dynamic.py +++ b/test/completion/dynamic.py @@ -30,9 +30,9 @@ def func(a): # *args, **args # ----------------- def arg(*args): - ##? tuple() + #? tuple() args - ##? int() + #? int() args[0] arg(1,"")