From 8494164b22b7d4af2e8762c63e48c3eeffce66f5 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Tue, 24 Apr 2018 00:41:18 +0200 Subject: [PATCH] Fix an async funcdef issue, fixes 1092. --- jedi/parser_utils.py | 4 +++- test/completion/async_.py | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/jedi/parser_utils.py b/jedi/parser_utils.py index 4ceced5c..bb033ed0 100644 --- a/jedi/parser_utils.py +++ b/jedi/parser_utils.py @@ -88,10 +88,12 @@ def get_flow_branch_keyword(flow_node, node): keyword = first_leaf return 0 + def get_statement_of_position(node, pos): for c in node.children: if c.start_pos <= pos <= c.end_pos: - if c.type not in ('decorated', 'simple_stmt', 'suite') \ + if c.type not in ('decorated', 'simple_stmt', 'suite', + 'async_stmt', 'async_funcdef') \ and not isinstance(c, (tree.Flow, tree.ClassOrFunc)): return c else: diff --git a/test/completion/async_.py b/test/completion/async_.py index a5484173..2af7fdda 100644 --- a/test/completion/async_.py +++ b/test/completion/async_.py @@ -73,3 +73,12 @@ async def wrapper(): asgen().__ane #? [] asgen().mro + + +# Normal completion (#1092) +normal_var1 = 42 + +async def foo(): + normal_var2 = False + #? ['normal_var1', 'normal_var2'] + normal_var