forked from VimPlug/jedi
Ensure variadic tuples (Tuple[T, ...]) behave like sequences
This commit is contained in:
@@ -385,8 +385,6 @@ def _infer_type_vars(annotation_value, value_set, is_class_value=False):
|
||||
)
|
||||
)
|
||||
elif annotation_name == 'Tuple':
|
||||
# TODO: check that this works both for fixed and variadic tuples
|
||||
# (and maybe for combiantions of those).
|
||||
# TODO: this logic is pretty similar to the general logic below, can
|
||||
# we combine them?
|
||||
|
||||
@@ -399,20 +397,32 @@ def _infer_type_vars(annotation_value, value_set, is_class_value=False):
|
||||
continue
|
||||
|
||||
annotation_generics = annotation_value.get_generics()
|
||||
actual_generics = py_class.get_generics()
|
||||
for annotation_generics_set, actual_generic_set in zip(annotation_generics, actual_generics):
|
||||
for nested_annotation_value in annotation_generics_set:
|
||||
tuple_annotation, = annotation_value.execute_annotation()
|
||||
# TODO: is can we avoid using this private method?
|
||||
if tuple_annotation._is_homogenous():
|
||||
for nested_annotation_value in annotation_generics[0]:
|
||||
_merge_type_var_dicts(
|
||||
type_var_dict,
|
||||
_infer_type_vars(
|
||||
nested_annotation_value,
|
||||
actual_generic_set,
|
||||
# This is a note to ourselves that we
|
||||
# have already converted the instance
|
||||
# representation to its class.
|
||||
is_class_value=True,
|
||||
value_set.merge_types_of_iterate(),
|
||||
),
|
||||
)
|
||||
else:
|
||||
actual_generics = py_class.get_generics()
|
||||
for annotation_generics_set, actual_generic_set in zip(annotation_generics, actual_generics):
|
||||
for nested_annotation_value in annotation_generics_set:
|
||||
_merge_type_var_dicts(
|
||||
type_var_dict,
|
||||
_infer_type_vars(
|
||||
nested_annotation_value,
|
||||
actual_generic_set,
|
||||
# This is a note to ourselves that we
|
||||
# have already converted the instance
|
||||
# representation to its class.
|
||||
is_class_value=True,
|
||||
),
|
||||
)
|
||||
elif isinstance(annotation_value, GenericClass):
|
||||
if annotation_name == 'Iterable' and not is_class_value:
|
||||
given = annotation_value.get_generics()
|
||||
|
||||
Reference in New Issue
Block a user