diff --git a/jedi/evaluate/context/instance.py b/jedi/evaluate/context/instance.py index 9c71d0b4..a51f5821 100644 --- a/jedi/evaluate/context/instance.py +++ b/jedi/evaluate/context/instance.py @@ -279,10 +279,12 @@ class TreeInstance(AbstractInstanceContext): continue all_annotations = pep0484.py__annotations__(execution.tree_node) - return pep0484.define_type_vars( + defined = pep0484.define_type_vars( self.class_context, pep0484.infer_type_vars_for_execution(execution, all_annotations), ) + debug.dbg('Inferred instance context as %s', defined, color='BLUE') + return defined return self.class_context def _get_annotation_init_functions(self): diff --git a/jedi/evaluate/context/typing.py b/jedi/evaluate/context/typing.py index 5f13a038..5f92bcaf 100644 --- a/jedi/evaluate/context/typing.py +++ b/jedi/evaluate/context/typing.py @@ -409,6 +409,10 @@ class TypeVar(_BaseTypingContext): debug.warning('Tried to infer the TypeVar %s without a given type', self._var_name) return NO_CONTEXTS + def is_same_class(self, other): + # Everything can match an undefined type var. + return True + @property def constraints(self): return ContextSet.from_sets( @@ -517,7 +521,8 @@ class _AbstractAnnotatedClass(ClassContext): # Now compare generics return all( any( - cls1.is_same_class(cls2) + # TODO why is this ordering the correct one? + cls2.is_same_class(cls1) for cls1 in class_set1 for cls2 in class_set2 ) for class_set1, class_set2 in zip(given_params1, given_params2)