diff --git a/jedi/evaluate/base_context.py b/jedi/evaluate/base_context.py index 055a62a8..7d9b2e87 100644 --- a/jedi/evaluate/base_context.py +++ b/jedi/evaluate/base_context.py @@ -300,6 +300,17 @@ class ContextSet(BaseContextSet): def get_item(self, *args, **kwargs): return ContextSet.from_sets(_getitem(c, *args, **kwargs) for c in self._set) + def try_merge(self, function_name): + context_set = self.__class__() + for c in self._set: + try: + method = getattr(c, function_name) + except AttributeError: + pass + else: + context_set |= method() + return context_set + NO_CONTEXTS = ContextSet() diff --git a/jedi/evaluate/context/function.py b/jedi/evaluate/context/function.py index 8eded724..f0ed1c8d 100644 --- a/jedi/evaluate/context/function.py +++ b/jedi/evaluate/context/function.py @@ -112,7 +112,7 @@ class FunctionContext(use_metaclass(CachedMetaClass, AbstractFunction)): def py__call__(self, arguments, need_param_match=False): function_execution = self.get_function_execution(arguments) - if need_param_match and function_execution.matches_signature(): + if need_param_match and not function_execution.matches_signature(): return NO_CONTEXTS return function_execution.infer() diff --git a/jedi/evaluate/context/instance.py b/jedi/evaluate/context/instance.py index d8827489..2d97fbb8 100644 --- a/jedi/evaluate/context/instance.py +++ b/jedi/evaluate/context/instance.py @@ -274,7 +274,6 @@ class TreeInstance(AbstractInstanceContext): # First check if the signature even matches, if not we don't # need to infer anything. continue - print(bound) context_set = define_type_vars_for_execution( ContextSet(self.class_context), execution, diff --git a/jedi/evaluate/context/typing.py b/jedi/evaluate/context/typing.py index cdc6458b..7b3f5408 100644 --- a/jedi/evaluate/context/typing.py +++ b/jedi/evaluate/context/typing.py @@ -406,7 +406,7 @@ class TypeVar(_BaseTypingContext): return ContextSet.from_sets( l.infer() for l in self._constraints_lazy_contexts ) - debug.warning('Tried to infer a TypeVar without a given type') + debug.warning('Tried to infer the TypeVar %r without a given type', self._var_name) return NO_CONTEXTS @property diff --git a/jedi/evaluate/pep0484.py b/jedi/evaluate/pep0484.py index 2378f984..70c90afd 100644 --- a/jedi/evaluate/pep0484.py +++ b/jedi/evaluate/pep0484.py @@ -256,14 +256,18 @@ def _infer_type_vars_for_execution(execution_context, annotation_dict): annotation_node = annotation_dict[executed_param.string_name] except KeyError: continue - if executed_param._param_node.star_count: # TODO remove this. - continue annotation_variables = find_unknown_type_vars(context, annotation_node) if annotation_variables: # Infer unknown type var annotation_context_set = context.eval_node(annotation_node) + star_count = executed_param._param_node.star_count actual_context_set = executed_param.infer(use_hints=False) + if star_count == 1: + actual_context_set = actual_context_set.merge_types_of_iterate() + elif star_count == 2: + # TODO _dict_values is not public. + actual_context_set = actual_context_set.try_merge('_dict_values') for ann in annotation_context_set: _merge_type_var_dicts( annotation_variable_results,