diff --git a/jedi/api/classes.py b/jedi/api/classes.py index d1566700..662c09e7 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -687,7 +687,7 @@ class ParamDefinition(Definition): :param execute_annotation: If False, the values are not executed and you get classes instead of instances. """ - return _values_to_definitions(self._name.infer_annotation(**kwargs)) + return _values_to_definitions(self._name.infer_annotation(ignore_stars=True, **kwargs)) def to_string(self): return self._name.to_string() diff --git a/jedi/inference/gradual/annotation.py b/jedi/inference/gradual/annotation.py index f291a1e4..76d76078 100644 --- a/jedi/inference/gradual/annotation.py +++ b/jedi/inference/gradual/annotation.py @@ -107,8 +107,10 @@ def _split_comment_param_declaration(decl_text): @inference_state_method_cache() -def infer_param(execution_context, param): +def infer_param(execution_context, param, ignore_stars=False): values = _infer_param(execution_context, param) + if ignore_stars: + return values inference_state = execution_context.inference_state if param.star_count == 1: tuple_ = builtin_from_name(inference_state, 'tuple') diff --git a/jedi/inference/names.py b/jedi/inference/names.py index ff06bf2e..0a6a668c 100644 --- a/jedi/inference/names.py +++ b/jedi/inference/names.py @@ -242,11 +242,11 @@ class ParamName(BaseTreeParamName): def annotation_node(self): return self._get_param_node().annotation - def infer_annotation(self, execute_annotation=True): - node = self.annotation_node - if node is None: - return NO_VALUES - values = self.parent_context.parent_context.infer_node(node) + def infer_annotation(self, execute_annotation=True, ignore_stars=False): + from jedi.inference.gradual.annotation import infer_param + values = infer_param( + self.parent_context, self._get_param_node(), + ignore_stars=ignore_stars) if execute_annotation: values = values.execute_annotation() return values @@ -299,6 +299,9 @@ class ParamName(BaseTreeParamName): return Parameter.POSITIONAL_OR_KEYWORD def infer(self): + values = self.infer_annotation() + if values: + return values return self.get_param().infer() def get_param(self): diff --git a/jedi/inference/param.py b/jedi/inference/param.py index f3d721e0..1b66c05c 100644 --- a/jedi/inference/param.py +++ b/jedi/inference/param.py @@ -33,9 +33,8 @@ class ExecutedParam(object): def infer(self, use_hints=True): if use_hints: doc_params = docstrings.infer_param(self._execution_context, self._param_node) - ann = self.infer_annotations().execute_annotation() - if ann or doc_params: - return ann | doc_params + if doc_params: + return doc_params return self._lazy_value.infer() diff --git a/test/completion/pep0484_basic.py b/test/completion/pep0484_basic.py index aef5437c..ba7cab18 100644 --- a/test/completion/pep0484_basic.py +++ b/test/completion/pep0484_basic.py @@ -24,7 +24,7 @@ def function_parameters(a: A, b, c: str, d: int, e: str, f: str, g: int=4): d #? str() e - #? int() str() + #? str() f # int() g