diff --git a/jedi/evaluate/pep0484.py b/jedi/evaluate/pep0484.py index 7fb03c20..57aee65c 100644 --- a/jedi/evaluate/pep0484.py +++ b/jedi/evaluate/pep0484.py @@ -38,7 +38,7 @@ from jedi import debug from jedi import parser_utils -def _evaluate_for_annotation(context, annotation, index=None): +def evaluate_for_annotation(context, annotation, index=None): """ Evaluates a string-node, looking for an annotation If index is not None, the annotation is expected to be a tuple @@ -174,7 +174,7 @@ def infer_param(execution_context, param): ) # Annotations are like default params and resolve in the same way. context = execution_context.function_context.get_default_param_context() - return _evaluate_for_annotation(context, annotation) + return evaluate_for_annotation(context, annotation) def py__annotations__(funcdef): diff --git a/jedi/evaluate/syntax_tree.py b/jedi/evaluate/syntax_tree.py index 19b36b57..69b4d470 100644 --- a/jedi/evaluate/syntax_tree.py +++ b/jedi/evaluate/syntax_tree.py @@ -17,7 +17,6 @@ from jedi.evaluate import helpers from jedi.evaluate import analysis from jedi.evaluate import imports from jedi.evaluate import arguments -from jedi.evaluate.pep0484 import _evaluate_for_annotation from jedi.evaluate.context import ClassContext, FunctionContext from jedi.evaluate.context import iterable from jedi.evaluate.context import TreeInstance, CompiledInstance @@ -131,7 +130,8 @@ def eval_node(context, element): elif typ == 'eval_input': return eval_node(context, element.children[0]) elif typ == 'annassign': - return pep0484._evaluate_for_annotation(context, element.children[1]) + return pep0484.evaluate_for_annotation(context, element.children[1]) \ + .execute_annotation() elif typ == 'yield_expr': if len(element.children) and element.children[1].type == 'yield_arg': # Implies that it's a yield from. @@ -535,7 +535,9 @@ def tree_name_to_contexts(evaluator, context, tree_name): correct_scope = parser_utils.get_parent_scope(name) == context.tree_node if expr_stmt.type == "expr_stmt" and expr_stmt.children[1].type == "annassign" and correct_scope: - context_set |= _evaluate_for_annotation(context, expr_stmt.children[1].children[1]) + context_set |= pep0484.evaluate_for_annotation( + context, expr_stmt.children[1].children[1] + ).execute_annotation() if context_set: return context_set