Add get_param_names to the function execution, which is needed to do some filtering

This commit is contained in:
Dave Halter
2019-09-03 09:22:31 +02:00
parent 1495a0ec4c
commit 35efdd84d2
2 changed files with 12 additions and 4 deletions

View File

@@ -208,9 +208,7 @@ 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.
# TODO private access
param_names, _ = value.parent_context._arguments.get_executed_param_names_and_issues(
value.parent_context._value)
param_names = value.parent_context.get_param_names()
if len(param_names) != 1:
continue
values = param_names[0].infer()

View File

@@ -10,7 +10,8 @@ from jedi.inference import flow_analysis
from jedi.inference.signature import TreeSignature
from jedi.inference.arguments import AnonymousArguments
from jedi.inference.filters import ParserTreeFilter, FunctionExecutionFilter
from jedi.inference.names import ValueName, AbstractNameDefinition, SimpleParamName
from jedi.inference.names import ValueName, AbstractNameDefinition, \
SimpleParamName, ParamName
from jedi.inference.base_value import ContextualizedNode, NO_VALUES, \
ValueSet, TreeValue, ValueWrapper
from jedi.inference.lazy_value import LazyKnownValues, LazyKnownValue, \
@@ -323,6 +324,15 @@ class FunctionExecutionContext(ValueContext, TreeContextMixin):
else:
return self.get_return_values()
def get_param_names(self):
if self._arguments is None:
return self._value.get_param_names()
else:
return [
ParamName(self._value, param.name, self._arguments)
for param in self._value.tree_node.get_params()
]
class OverloadedFunctionValue(FunctionMixin, ValueWrapper):
def __init__(self, function, overloaded_functions):