diff --git a/jedi/inference/syntax_tree.py b/jedi/inference/syntax_tree.py index 8311edc77..39503a658 100644 --- a/jedi/inference/syntax_tree.py +++ b/jedi/inference/syntax_tree.py @@ -696,11 +696,11 @@ def tree_name_to_values(inference_state, context, tree_name): if expr_stmt.type == "expr_stmt" and expr_stmt.children[1].type == "annassign": correct_scope = parser_utils.get_parent_scope(name) == context.tree_node ann_assign = expr_stmt.children[1] - if correct_scope and name.start_pos < ann_assign.start_pos: + if correct_scope: found_annotation = True if ( - (expr_stmt.children[1].children[1].type == 'name') - and (expr_stmt.children[1].children[1].value == tree_name.value) + (ann_assign.children[1].type == 'name') + and (ann_assign.children[1].value == tree_name.value) and context.parent_context ): context = context.parent_context diff --git a/test/completion/pep0484_basic.py b/test/completion/pep0484_basic.py index e20fe4408..7ead7382d 100644 --- a/test/completion/pep0484_basic.py +++ b/test/completion/pep0484_basic.py @@ -180,6 +180,11 @@ def argskwargs(*args: int, **kwargs: float): #? float() kwargs[''] +class Test: + str: str = 'abc' + +#? ['upper'] +Test.str.upp class NotCalledClass: def __init__(self, x):