mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-21 19:32:06 +08:00
Use get_kind in ExecutedParam
This commit is contained in:
@@ -9,7 +9,7 @@ import re
|
||||
|
||||
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.base_value import ValueSet, NO_VALUES
|
||||
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:
|
||||
# Infer unknown type var
|
||||
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)
|
||||
if star_count == 1:
|
||||
if kind is Parameter.VAR_POSITIONAL:
|
||||
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.
|
||||
actual_value_set = actual_value_set.try_merge('_dict_values')
|
||||
for ann in annotation_value_set:
|
||||
|
||||
@@ -6,6 +6,7 @@ from jedi.inference import analysis
|
||||
from jedi.inference.lazy_value import LazyKnownValue, \
|
||||
LazyTreeValue, LazyUnknownValue
|
||||
from jedi.inference.value import iterable
|
||||
from jedi._compatibility import Parameter
|
||||
|
||||
|
||||
def _add_argument_issue(error_name, lazy_value, message):
|
||||
@@ -20,7 +21,6 @@ class ExecutedParam(object):
|
||||
"""Fake a param and give it values."""
|
||||
def __init__(self, execution_context, param_node, lazy_value, is_default=False):
|
||||
self._execution_context = execution_context
|
||||
self._param_node = param_node
|
||||
from jedi.inference.names import ParamName
|
||||
self._name = ParamName(execution_context, param_node.name)
|
||||
self._lazy_value = lazy_value
|
||||
@@ -30,11 +30,14 @@ class ExecutedParam(object):
|
||||
def infer(self, use_hints=True):
|
||||
return self._lazy_value.infer()
|
||||
|
||||
def get_kind(self):
|
||||
return self._name.get_kind()
|
||||
|
||||
def matches_signature(self):
|
||||
if self._is_default:
|
||||
return True
|
||||
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
|
||||
annotations = self._name.infer_annotation(execute_annotation=False)
|
||||
if not annotations:
|
||||
|
||||
Reference in New Issue
Block a user