Remove dict merging where it doesn't do anything

These cases are all at the end of a single-path branch that ends
up "merging" against an empty mapping which is then returned
unchanged.
This commit is contained in:
Peter Law
2020-03-22 15:40:29 +00:00
parent f68d65ed59
commit ea33db388b
2 changed files with 9 additions and 21 deletions

View File

@@ -209,11 +209,8 @@ class GenericClass(ClassMixin, DefineGenericBase):
if annotation_name == 'Iterable' and not is_class_value:
given = self.get_generics()
if given:
merge_type_var_dicts(
type_var_dict,
given[0].infer_type_vars(
value_set.merge_types_of_iterate(),
),
return given[0].infer_type_vars(
value_set.merge_types_of_iterate(),
)
else:
# Note: we need to handle the MRO _in order_, so we need to extract

View File

@@ -200,22 +200,16 @@ class TypingClassValueWithIndex(_TypingClassMixin, TypingValueWithIndex):
)
else:
merge_type_var_dicts(
type_var_dict,
given[0].infer_type_vars(
value_set,
is_class_value=True,
),
return given[0].infer_type_vars(
value_set,
is_class_value=True,
)
elif annotation_name == 'Callable':
given = self.get_generics()
if len(given) == 2:
merge_type_var_dicts(
type_var_dict,
given[1].infer_type_vars(
value_set.execute_annotation(),
),
return given[1].infer_type_vars(
value_set.execute_annotation(),
)
elif annotation_name == 'Tuple':
@@ -226,11 +220,8 @@ class TypingClassValueWithIndex(_TypingClassMixin, TypingValueWithIndex):
# The parameter annotation is of the form `Tuple[T, ...]`,
# so we treat the incoming tuple like a iterable sequence
# rather than a positional container of elements.
merge_type_var_dicts(
type_var_dict,
annotation_generics[0].infer_type_vars(
value_set.merge_types_of_iterate(),
),
return annotation_generics[0].infer_type_vars(
value_set.merge_types_of_iterate(),
)
else: