Some more renames

This commit is contained in:
Dave Halter
2019-08-24 14:02:04 +02:00
parent 622db8d2d7
commit 98d0fc632e
6 changed files with 29 additions and 28 deletions

View File

@@ -26,7 +26,7 @@ from jedi.inference.param import create_default_params
from jedi.inference.helpers import is_stdlib_path
from jedi.inference.utils import to_list
from jedi.parser_utils import get_parent_scope
from jedi.inference.value import ModuleValue, instance
from jedi.inference.value import instance
from jedi.inference.base_value import ValueSet, NO_VALUES
from jedi.inference import recursion
@@ -39,9 +39,9 @@ class DynamicExecutedParams(object):
Simulates being a parameter while actually just being multiple params.
"""
def __init__(self, inference_state, executed_params):
def __init__(self, inference_state, executed_param_names):
self.inference_state = inference_state
self._executed_params = executed_params
self._executed_param_names = executed_param_names
def infer(self):
with recursion.execution_allowed(self.inference_state, self) as allowed:
@@ -49,7 +49,7 @@ class DynamicExecutedParams(object):
# anonymous functions can create an anonymous parameter that is
# more or less self referencing.
if allowed:
return ValueSet.from_sets(p.infer() for p in self._executed_params)
return ValueSet.from_sets(p.infer() for p in self._executed_param_names)
return NO_VALUES
@@ -97,12 +97,12 @@ def search_param_names(inference_state, execution_context, funcdef):
string_name=string_name,
)
if function_executions:
zipped_params = zip(*list(
zipped_param_names = zip(*list(
function_execution.get_executed_param_names_and_issues()[0]
for function_execution in function_executions
))
params = [DynamicExecutedParams(inference_state, executed_params)
for executed_params in zipped_params]
params = [DynamicExecutedParams(inference_state, executed_param_names)
for executed_param_names in zipped_param_names]
else:
return create_default_params(execution_context, funcdef)
finally:
@@ -129,7 +129,7 @@ def _search_function_executions(inference_state, module_context, funcdef, string
i = 0
for for_mod_context in imports.get_module_contexts_containing_name(
inference_state, [module_context], string_name):
for name, trailer in _get_possible_nodes(for_mod_context, string_name):
for name, trailer in _get_potential_nodes(for_mod_context, string_name):
i += 1
# This is a simple way to stop Jedi's dynamic param recursion
@@ -162,7 +162,7 @@ def _get_lambda_name(node):
return None
def _get_possible_nodes(module_value, func_string_name):
def _get_potential_nodes(module_value, func_string_name):
try:
names = module_value.tree_node.get_used_names()[func_string_name]
except KeyError:
@@ -205,16 +205,17 @@ def _check_name_for_execution(inference_state, context, compare_node, name, trai
# 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.
params, _ = value.parent_context.get_executed_param_names_and_issues()
if len(params) != 1:
param_names, _ = value.parent_context.get_executed_param_names_and_issues()
if len(param_names) != 1:
continue
values = params[0].infer()
values = param_names[0].infer()
nodes = [v.tree_node for v in values]
if nodes == [compare_node]:
# Found a decorator.
module_context = context.get_root_context()
execution_context = next(create_func_excs(value))
for name, trailer in _get_possible_nodes(module_context, params[0].string_name):
potential_nodes = _get_potential_nodes(module_context, param_names[0].string_name)
for name, trailer in potential_nodes:
if value_node.start_pos < name.start_pos < value_node.end_pos:
random_context = execution_context.create_context(name)
iterator = _check_name_for_execution(

View File

@@ -246,10 +246,10 @@ def infer_type_vars_for_execution(execution_context, annotation_dict):
context = execution_context.function_value.get_default_param_context()
annotation_variable_results = {}
executed_params, _ = execution_context.get_executed_param_names_and_issues()
for executed_param in executed_params:
executed_param_names, _ = execution_context.get_executed_param_names_and_issues()
for executed_param_name in executed_param_names:
try:
annotation_node = annotation_dict[executed_param.string_name]
annotation_node = annotation_dict[executed_param_name.string_name]
except KeyError:
continue
@@ -257,8 +257,8 @@ def infer_type_vars_for_execution(execution_context, annotation_dict):
if annotation_variables:
# Infer unknown type var
annotation_value_set = context.infer_node(annotation_node)
kind = executed_param.get_kind()
actual_value_set = executed_param.infer(use_hints=False)
kind = executed_param_name.get_kind()
actual_value_set = executed_param_name.infer()
if kind is Parameter.VAR_POSITIONAL:
actual_value_set = actual_value_set.merge_types_of_iterate()
elif kind is Parameter.VAR_KEYWORD:

View File

@@ -313,9 +313,9 @@ class ParamName(BaseTreeParamName):
return self.get_param().infer()
def get_param(self):
params, _ = self.parent_context.get_executed_param_names_and_issues()
params_names, _ = self.parent_context.get_executed_param_names_and_issues()
param_node = search_ancestor(self.tree_name, 'param')
return params[param_node.position_index]
return params_names[param_node.position_index]
class ParamNameWrapper(_ParamMixin):

View File

@@ -25,13 +25,13 @@ class ExecutedParamName(ParamName):
self._lazy_value = lazy_value
self._is_default = is_default
def infer(self, use_hints=True):
def infer(self):
return self._lazy_value.infer()
def matches_signature(self):
if self._is_default:
return True
argument_values = self.infer(use_hints=False).py__class__()
argument_values = self.infer().py__class__()
if self.get_kind() in (Parameter.VAR_POSITIONAL, Parameter.VAR_KEYWORD):
return True
annotations = self.infer_annotation(execute_annotation=False)

View File

@@ -290,12 +290,12 @@ class FunctionExecutionContext(ValueContext, TreeContextMixin):
return self.var_args.get_executed_param_names_and_issues(self)
def matches_signature(self):
executed_params, issues = self.get_executed_param_names_and_issues()
executed_param_names, issues = self.get_executed_param_names_and_issues()
if issues:
return False
matches = all(executed_param.matches_signature()
for executed_param in executed_params)
matches = all(executed_param_name.matches_signature()
for executed_param_name in executed_param_names)
if debug.enable_notice:
signature = parser_utils.get_call_signature(self.tree_node)
if matches:

View File

@@ -51,13 +51,13 @@ class AnonymousInstanceArguments(AnonymousArguments):
# If the only param is self, we don't need to try to find
# executions of this function, we have all the params already.
return [self_param], []
executed_params = list(search_param_names(
executed_param_names = list(search_param_names(
execution_context.inference_state,
execution_context,
execution_context.tree_node
))
executed_params[0] = self_param
return executed_params, []
executed_param_names[0] = self_param
return executed_param_names, []
class AbstractInstanceValue(Value):