From 6814a7336c46a3dca0378b21783bdf8e76d25c66 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sun, 25 Jul 2021 15:23:51 +0100 Subject: [PATCH] Hoist common variable for additional re-use --- jedi/inference/gradual/annotation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jedi/inference/gradual/annotation.py b/jedi/inference/gradual/annotation.py index eadcfc2e..b4caeb5e 100644 --- a/jedi/inference/gradual/annotation.py +++ b/jedi/inference/gradual/annotation.py @@ -202,6 +202,7 @@ def infer_return_types(function, arguments): Infers the type of a function's return value, according to type annotations. """ + context = function.get_default_param_context() all_annotations = py__annotations__(function.tree_node) annotation = all_annotations.get("return", None) if annotation is None: @@ -217,11 +218,10 @@ def infer_return_types(function, arguments): return NO_VALUES return _infer_annotation_string( - function.get_default_param_context(), + context, match.group(1).strip() ).execute_annotation() - context = function.get_default_param_context() unknown_type_vars = find_unknown_type_vars(context, annotation) annotation_values = infer_annotation(context, annotation) if not unknown_type_vars: