Skip to content

Commit

Permalink
Fix issue around completions with multiple with with_items, fixes 1931
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhalter committed Jul 27, 2023
1 parent cd4ca74 commit 6ea5ad7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jedi/inference/gradual/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ def find_type_from_comment_hint_for(context, node, name):


def find_type_from_comment_hint_with(context, node, name):
if len(node.children) > 4:
# In case there are multiple with_items, we do not want a type hint for
# now.
return []
assert len(node.children[1].children) == 3, \
"Can only be here when children[1] is 'foo() as f'"
varlist = node.children[1].children[2]
Expand Down
4 changes: 4 additions & 0 deletions test/completion/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ def __enter__(self):
with Foo() as f3:
f3

with open("a"), open("b") as bfile:
#? ['flush']
bfile.flush

# -----------------
# Avoiding multiple definitions
# -----------------
Expand Down

0 comments on commit 6ea5ad7

Please sign in to comment.