From 6ea5ad7b192cca53d312737a191faab7680dd3f9 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 27 Jul 2023 11:54:39 +0200 Subject: [PATCH] Fix issue around completions with multiple with with_items, fixes 1931 --- jedi/inference/gradual/annotation.py | 4 ++++ test/completion/basic.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/jedi/inference/gradual/annotation.py b/jedi/inference/gradual/annotation.py index 81780010..57098276 100644 --- a/jedi/inference/gradual/annotation.py +++ b/jedi/inference/gradual/annotation.py @@ -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] diff --git a/test/completion/basic.py b/test/completion/basic.py index 97bfeecd..53df851e 100644 --- a/test/completion/basic.py +++ b/test/completion/basic.py @@ -413,6 +413,10 @@ with Foo() as f3: with Foo() as f3: f3 +with open("a"), open("b") as bfile: + #? ['flush'] + bfile.flush + # ----------------- # Avoiding multiple definitions # -----------------