Hoist common variable for additional re-use

This commit is contained in:
Peter Law
2021-07-25 15:23:51 +01:00
parent 070f191f55
commit 6814a7336c

View File

@@ -202,6 +202,7 @@ def infer_return_types(function, arguments):
Infers the type of a function's return value, Infers the type of a function's return value,
according to type annotations. according to type annotations.
""" """
context = function.get_default_param_context()
all_annotations = py__annotations__(function.tree_node) all_annotations = py__annotations__(function.tree_node)
annotation = all_annotations.get("return", None) annotation = all_annotations.get("return", None)
if annotation is None: if annotation is None:
@@ -217,11 +218,10 @@ def infer_return_types(function, arguments):
return NO_VALUES return NO_VALUES
return _infer_annotation_string( return _infer_annotation_string(
function.get_default_param_context(), context,
match.group(1).strip() match.group(1).strip()
).execute_annotation() ).execute_annotation()
context = function.get_default_param_context()
unknown_type_vars = find_unknown_type_vars(context, annotation) unknown_type_vars = find_unknown_type_vars(context, annotation)
annotation_values = infer_annotation(context, annotation) annotation_values = infer_annotation(context, annotation)
if not unknown_type_vars: if not unknown_type_vars: