1
0
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:
Dave Halter
2018-09-23 00:41:32 +02:00
parent 994e7d1910
commit f435f23570
2 changed files with 9 additions and 2 deletions

View File

@@ -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):

View File

@@ -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)