forked from VimPlug/jedi
Small changes so some type var inferring works better
However this change is a bit controversial, because it involves some strange class matching that we might need to revisit
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user