forked from VimPlug/jedi
Use get_kind in ExecutedParam
This commit is contained in:
@@ -9,7 +9,7 @@ import re
|
|||||||
|
|
||||||
from parso import ParserSyntaxError, parse
|
from parso import ParserSyntaxError, parse
|
||||||
|
|
||||||
from jedi._compatibility import force_unicode
|
from jedi._compatibility import force_unicode, Parameter
|
||||||
from jedi.inference.cache import inference_state_method_cache
|
from jedi.inference.cache import inference_state_method_cache
|
||||||
from jedi.inference.base_value import ValueSet, NO_VALUES
|
from jedi.inference.base_value import ValueSet, NO_VALUES
|
||||||
from jedi.inference.gradual.typing import TypeVar, LazyGenericClass, \
|
from jedi.inference.gradual.typing import TypeVar, LazyGenericClass, \
|
||||||
@@ -257,11 +257,11 @@ 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)
|
||||||
star_count = executed_param._param_node.star_count
|
kind = executed_param.get_kind()
|
||||||
actual_value_set = executed_param.infer(use_hints=False)
|
actual_value_set = executed_param.infer(use_hints=False)
|
||||||
if star_count == 1:
|
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 star_count == 2:
|
elif kind is Parameter.VAR_KEYWORD:
|
||||||
# TODO _dict_values is not public.
|
# TODO _dict_values is not public.
|
||||||
actual_value_set = actual_value_set.try_merge('_dict_values')
|
actual_value_set = actual_value_set.try_merge('_dict_values')
|
||||||
for ann in annotation_value_set:
|
for ann in annotation_value_set:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from jedi.inference import analysis
|
|||||||
from jedi.inference.lazy_value import LazyKnownValue, \
|
from jedi.inference.lazy_value import LazyKnownValue, \
|
||||||
LazyTreeValue, LazyUnknownValue
|
LazyTreeValue, LazyUnknownValue
|
||||||
from jedi.inference.value import iterable
|
from jedi.inference.value import iterable
|
||||||
|
from jedi._compatibility import Parameter
|
||||||
|
|
||||||
|
|
||||||
def _add_argument_issue(error_name, lazy_value, message):
|
def _add_argument_issue(error_name, lazy_value, message):
|
||||||
@@ -20,7 +21,6 @@ class ExecutedParam(object):
|
|||||||
"""Fake a param and give it values."""
|
"""Fake a param and give it values."""
|
||||||
def __init__(self, execution_context, param_node, lazy_value, is_default=False):
|
def __init__(self, execution_context, param_node, lazy_value, is_default=False):
|
||||||
self._execution_context = execution_context
|
self._execution_context = execution_context
|
||||||
self._param_node = param_node
|
|
||||||
from jedi.inference.names import ParamName
|
from jedi.inference.names import ParamName
|
||||||
self._name = ParamName(execution_context, param_node.name)
|
self._name = ParamName(execution_context, param_node.name)
|
||||||
self._lazy_value = lazy_value
|
self._lazy_value = lazy_value
|
||||||
@@ -30,11 +30,14 @@ class ExecutedParam(object):
|
|||||||
def infer(self, use_hints=True):
|
def infer(self, use_hints=True):
|
||||||
return self._lazy_value.infer()
|
return self._lazy_value.infer()
|
||||||
|
|
||||||
|
def get_kind(self):
|
||||||
|
return self._name.get_kind()
|
||||||
|
|
||||||
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(use_hints=False).py__class__()
|
||||||
if self._param_node.star_count:
|
if self._name.get_kind() in (Parameter.VAR_POSITIONAL, Parameter.VAR_KEYWORD):
|
||||||
return True
|
return True
|
||||||
annotations = self._name.infer_annotation(execute_annotation=False)
|
annotations = self._name.infer_annotation(execute_annotation=False)
|
||||||
if not annotations:
|
if not annotations:
|
||||||
|
|||||||
Reference in New Issue
Block a user