forked from VimPlug/jedi
Some more renames
This commit is contained in:
@@ -26,7 +26,7 @@ from jedi.inference.param import create_default_params
|
|||||||
from jedi.inference.helpers import is_stdlib_path
|
from jedi.inference.helpers import is_stdlib_path
|
||||||
from jedi.inference.utils import to_list
|
from jedi.inference.utils import to_list
|
||||||
from jedi.parser_utils import get_parent_scope
|
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.base_value import ValueSet, NO_VALUES
|
||||||
from jedi.inference import recursion
|
from jedi.inference import recursion
|
||||||
|
|
||||||
@@ -39,9 +39,9 @@ class DynamicExecutedParams(object):
|
|||||||
Simulates being a parameter while actually just being multiple params.
|
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.inference_state = inference_state
|
||||||
self._executed_params = executed_params
|
self._executed_param_names = executed_param_names
|
||||||
|
|
||||||
def infer(self):
|
def infer(self):
|
||||||
with recursion.execution_allowed(self.inference_state, self) as allowed:
|
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
|
# anonymous functions can create an anonymous parameter that is
|
||||||
# more or less self referencing.
|
# more or less self referencing.
|
||||||
if allowed:
|
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
|
return NO_VALUES
|
||||||
|
|
||||||
|
|
||||||
@@ -97,12 +97,12 @@ def search_param_names(inference_state, execution_context, funcdef):
|
|||||||
string_name=string_name,
|
string_name=string_name,
|
||||||
)
|
)
|
||||||
if function_executions:
|
if function_executions:
|
||||||
zipped_params = zip(*list(
|
zipped_param_names = zip(*list(
|
||||||
function_execution.get_executed_param_names_and_issues()[0]
|
function_execution.get_executed_param_names_and_issues()[0]
|
||||||
for function_execution in function_executions
|
for function_execution in function_executions
|
||||||
))
|
))
|
||||||
params = [DynamicExecutedParams(inference_state, executed_params)
|
params = [DynamicExecutedParams(inference_state, executed_param_names)
|
||||||
for executed_params in zipped_params]
|
for executed_param_names in zipped_param_names]
|
||||||
else:
|
else:
|
||||||
return create_default_params(execution_context, funcdef)
|
return create_default_params(execution_context, funcdef)
|
||||||
finally:
|
finally:
|
||||||
@@ -129,7 +129,7 @@ def _search_function_executions(inference_state, module_context, funcdef, string
|
|||||||
i = 0
|
i = 0
|
||||||
for for_mod_context in imports.get_module_contexts_containing_name(
|
for for_mod_context in imports.get_module_contexts_containing_name(
|
||||||
inference_state, [module_context], string_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
|
i += 1
|
||||||
|
|
||||||
# This is a simple way to stop Jedi's dynamic param recursion
|
# This is a simple way to stop Jedi's dynamic param recursion
|
||||||
@@ -162,7 +162,7 @@ def _get_lambda_name(node):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _get_possible_nodes(module_value, func_string_name):
|
def _get_potential_nodes(module_value, func_string_name):
|
||||||
try:
|
try:
|
||||||
names = module_value.tree_node.get_used_names()[func_string_name]
|
names = module_value.tree_node.get_used_names()[func_string_name]
|
||||||
except KeyError:
|
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
|
# Here we're trying to find decorators by checking the first
|
||||||
# parameter. It's not very generic though. Should find a better
|
# parameter. It's not very generic though. Should find a better
|
||||||
# solution that also applies to nested decorators.
|
# solution that also applies to nested decorators.
|
||||||
params, _ = value.parent_context.get_executed_param_names_and_issues()
|
param_names, _ = value.parent_context.get_executed_param_names_and_issues()
|
||||||
if len(params) != 1:
|
if len(param_names) != 1:
|
||||||
continue
|
continue
|
||||||
values = params[0].infer()
|
values = param_names[0].infer()
|
||||||
nodes = [v.tree_node for v in values]
|
nodes = [v.tree_node for v in values]
|
||||||
if nodes == [compare_node]:
|
if nodes == [compare_node]:
|
||||||
# Found a decorator.
|
# Found a decorator.
|
||||||
module_context = context.get_root_context()
|
module_context = context.get_root_context()
|
||||||
execution_context = next(create_func_excs(value))
|
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:
|
if value_node.start_pos < name.start_pos < value_node.end_pos:
|
||||||
random_context = execution_context.create_context(name)
|
random_context = execution_context.create_context(name)
|
||||||
iterator = _check_name_for_execution(
|
iterator = _check_name_for_execution(
|
||||||
|
|||||||
@@ -246,10 +246,10 @@ def infer_type_vars_for_execution(execution_context, annotation_dict):
|
|||||||
context = execution_context.function_value.get_default_param_context()
|
context = execution_context.function_value.get_default_param_context()
|
||||||
|
|
||||||
annotation_variable_results = {}
|
annotation_variable_results = {}
|
||||||
executed_params, _ = execution_context.get_executed_param_names_and_issues()
|
executed_param_names, _ = execution_context.get_executed_param_names_and_issues()
|
||||||
for executed_param in executed_params:
|
for executed_param_name in executed_param_names:
|
||||||
try:
|
try:
|
||||||
annotation_node = annotation_dict[executed_param.string_name]
|
annotation_node = annotation_dict[executed_param_name.string_name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -257,8 +257,8 @@ def infer_type_vars_for_execution(execution_context, annotation_dict):
|
|||||||
if annotation_variables:
|
if annotation_variables:
|
||||||
# Infer unknown type var
|
# Infer unknown type var
|
||||||
annotation_value_set = context.infer_node(annotation_node)
|
annotation_value_set = context.infer_node(annotation_node)
|
||||||
kind = executed_param.get_kind()
|
kind = executed_param_name.get_kind()
|
||||||
actual_value_set = executed_param.infer(use_hints=False)
|
actual_value_set = executed_param_name.infer()
|
||||||
if kind is Parameter.VAR_POSITIONAL:
|
if kind is Parameter.VAR_POSITIONAL:
|
||||||
actual_value_set = actual_value_set.merge_types_of_iterate()
|
actual_value_set = actual_value_set.merge_types_of_iterate()
|
||||||
elif kind is Parameter.VAR_KEYWORD:
|
elif kind is Parameter.VAR_KEYWORD:
|
||||||
|
|||||||
@@ -313,9 +313,9 @@ class ParamName(BaseTreeParamName):
|
|||||||
return self.get_param().infer()
|
return self.get_param().infer()
|
||||||
|
|
||||||
def get_param(self):
|
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')
|
param_node = search_ancestor(self.tree_name, 'param')
|
||||||
return params[param_node.position_index]
|
return params_names[param_node.position_index]
|
||||||
|
|
||||||
|
|
||||||
class ParamNameWrapper(_ParamMixin):
|
class ParamNameWrapper(_ParamMixin):
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ class ExecutedParamName(ParamName):
|
|||||||
self._lazy_value = lazy_value
|
self._lazy_value = lazy_value
|
||||||
self._is_default = is_default
|
self._is_default = is_default
|
||||||
|
|
||||||
def infer(self, use_hints=True):
|
def infer(self):
|
||||||
return self._lazy_value.infer()
|
return self._lazy_value.infer()
|
||||||
|
|
||||||
def matches_signature(self):
|
def matches_signature(self):
|
||||||
if self._is_default:
|
if self._is_default:
|
||||||
return True
|
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):
|
if self.get_kind() in (Parameter.VAR_POSITIONAL, Parameter.VAR_KEYWORD):
|
||||||
return True
|
return True
|
||||||
annotations = self.infer_annotation(execute_annotation=False)
|
annotations = self.infer_annotation(execute_annotation=False)
|
||||||
|
|||||||
@@ -290,12 +290,12 @@ class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
|||||||
return self.var_args.get_executed_param_names_and_issues(self)
|
return self.var_args.get_executed_param_names_and_issues(self)
|
||||||
|
|
||||||
def matches_signature(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:
|
if issues:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
matches = all(executed_param.matches_signature()
|
matches = all(executed_param_name.matches_signature()
|
||||||
for executed_param in executed_params)
|
for executed_param_name in executed_param_names)
|
||||||
if debug.enable_notice:
|
if debug.enable_notice:
|
||||||
signature = parser_utils.get_call_signature(self.tree_node)
|
signature = parser_utils.get_call_signature(self.tree_node)
|
||||||
if matches:
|
if matches:
|
||||||
|
|||||||
@@ -51,13 +51,13 @@ class AnonymousInstanceArguments(AnonymousArguments):
|
|||||||
# If the only param is self, we don't need to try to find
|
# If the only param is self, we don't need to try to find
|
||||||
# executions of this function, we have all the params already.
|
# executions of this function, we have all the params already.
|
||||||
return [self_param], []
|
return [self_param], []
|
||||||
executed_params = list(search_param_names(
|
executed_param_names = list(search_param_names(
|
||||||
execution_context.inference_state,
|
execution_context.inference_state,
|
||||||
execution_context,
|
execution_context,
|
||||||
execution_context.tree_node
|
execution_context.tree_node
|
||||||
))
|
))
|
||||||
executed_params[0] = self_param
|
executed_param_names[0] = self_param
|
||||||
return executed_params, []
|
return executed_param_names, []
|
||||||
|
|
||||||
|
|
||||||
class AbstractInstanceValue(Value):
|
class AbstractInstanceValue(Value):
|
||||||
|
|||||||
Reference in New Issue
Block a user