Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1988 #1989

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions jedi/inference/syntax_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,15 @@ 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:
found_annotation = True
if (
(ann_assign.children[1].type == 'name')
and (ann_assign.children[1].value == tree_name.value)
and context.parent_context
):
context = context.parent_context
value_set |= annotation.infer_annotation(
context, expr_stmt.children[1].children[1]
).execute_annotation()
Expand Down
5 changes: 5 additions & 0 deletions test/completion/pep0484_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading