mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Hoist common variable for additional re-use
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user