From fe8a605d4ac08d87d76683d4f34551d1ca62fa5d Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Tue, 3 Sep 2019 00:30:22 +0200 Subject: [PATCH] Remove get_executed_param_names_and_issues from FunctionExecution --- jedi/inference/dynamic_params.py | 31 +++++++++++++++++-------------- jedi/inference/names.py | 3 ++- jedi/inference/value/function.py | 3 --- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/jedi/inference/dynamic_params.py b/jedi/inference/dynamic_params.py index 3bef3ce1..c8e11d70 100644 --- a/jedi/inference/dynamic_params.py +++ b/jedi/inference/dynamic_params.py @@ -92,16 +92,16 @@ def search_param_names(inference_state, function_value, funcdef): try: module_context = function_value.get_root_context() - function_executions = _search_function_executions( + arguments_list = _search_function_arguments( inference_state, module_context, funcdef, string_name=string_name, ) - if function_executions: + if arguments_list: zipped_param_names = zip(*list( - function_execution.get_executed_param_names_and_issues()[0] - for function_execution in function_executions + arguments.get_executed_param_names_and_issues(function_value)[0] + for arguments in arguments_list )) params = [DynamicExecutedParamName(executed_param_names) for executed_param_names in zipped_param_names] @@ -116,7 +116,7 @@ def search_param_names(inference_state, function_value, funcdef): @inference_state_function_cache(default=None) @to_list -def _search_function_executions(inference_state, module_context, funcdef, string_name): +def _search_function_arguments(inference_state, module_context, funcdef, string_name): """ Returns a list of param names. """ @@ -127,7 +127,7 @@ def _search_function_executions(inference_state, module_context, funcdef, string string_name = cls.name.value compare_node = cls - found_executions = False + found_arguments = False i = 0 for for_mod_context in imports.get_module_contexts_containing_name( inference_state, [module_context], string_name): @@ -141,14 +141,14 @@ def _search_function_executions(inference_state, module_context, funcdef, string return random_context = for_mod_context.create_context(name) - for function_execution in _check_name_for_execution( + for arguments in _check_name_for_execution( inference_state, random_context, compare_node, name, trailer): - found_executions = True - yield function_execution + found_arguments = True + yield arguments # If there are results after processing a module, we're probably # good to process. This is a speed optimization. - if found_executions: + if found_arguments: return @@ -201,13 +201,16 @@ def _check_name_for_execution(inference_state, context, compare_node, name, trai value_node = value.tree_node if compare_node == value_node: for func_execution in create_func_excs(value): - yield func_execution + # TODO private access + yield func_execution._arguments elif isinstance(value.parent_context, FunctionExecutionContext) and \ compare_node.type == 'funcdef': # Here we're trying to find decorators by checking the first # parameter. It's not very generic though. Should find a better # solution that also applies to nested decorators. - param_names, _ = value.parent_context.get_executed_param_names_and_issues() + # TODO private access + param_names, _ = value.parent_context._arguments.get_executed_param_names_and_issues( + value.parent_context._value) if len(param_names) != 1: continue values = param_names[0].infer() @@ -227,5 +230,5 @@ def _check_name_for_execution(inference_state, context, compare_node, name, trai name, trailer ) - for function_execution in iterator: - yield function_execution + for arguments in iterator: + yield arguments diff --git a/jedi/inference/names.py b/jedi/inference/names.py index 6c26d3cc..8664dcb0 100644 --- a/jedi/inference/names.py +++ b/jedi/inference/names.py @@ -329,7 +329,8 @@ class SimpleParamName(X): def infer(self): func_context = self.function_value.as_context() - param_names, _ = func_context.get_executed_param_names_and_issues() + # TODO private access + param_names, _ = func_context._arguments.get_executed_param_names_and_issues(self.function_value) return param_names[self._get_param_node().position_index].infer() diff --git a/jedi/inference/value/function.py b/jedi/inference/value/function.py index ce35562c..c03e38af 100644 --- a/jedi/inference/value/function.py +++ b/jedi/inference/value/function.py @@ -285,9 +285,6 @@ class FunctionExecutionContext(ValueContext, TreeContextMixin): arguments=self._arguments ) - def get_executed_param_names_and_issues(self): - return self._arguments.get_executed_param_names_and_issues(self._value) - def infer(self): """ Created to be used by inheritance.