mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Make nested Type[T] annotations work
This commit is contained in:
@@ -343,15 +343,36 @@ def _infer_type_vars(annotation_value, value_set, is_class_value=False):
|
|||||||
if annotation_name == 'Type':
|
if annotation_name == 'Type':
|
||||||
given = annotation_value.get_generics()
|
given = annotation_value.get_generics()
|
||||||
if given:
|
if given:
|
||||||
for nested_annotation_value in given[0]:
|
if is_class_value:
|
||||||
_merge_type_var_dicts(
|
for element in value_set:
|
||||||
type_var_dict,
|
element_name = element.py__name__()
|
||||||
_infer_type_vars(
|
if annotation_name == element_name:
|
||||||
nested_annotation_value,
|
annotation_generics = annotation_value.get_generics()
|
||||||
value_set,
|
actual_generics = element.get_generics()
|
||||||
is_class_value=True,
|
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
for nested_annotation_value in given[0]:
|
||||||
|
_merge_type_var_dicts(
|
||||||
|
type_var_dict,
|
||||||
|
_infer_type_vars(
|
||||||
|
nested_annotation_value,
|
||||||
|
value_set,
|
||||||
|
is_class_value=True,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
elif annotation_name == 'Callable':
|
elif annotation_name == 'Callable':
|
||||||
given = annotation_value.get_generics()
|
given = annotation_value.get_generics()
|
||||||
if len(given) == 2:
|
if len(given) == 2:
|
||||||
|
|||||||
Reference in New Issue
Block a user