From fc8326bca1a69ae5e11d76a92e228d72ca47ba71 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sun, 3 Sep 2017 00:07:14 +0200 Subject: [PATCH] Finally get rid of the last get_definition. --- jedi/api/helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jedi/api/helpers.py b/jedi/api/helpers.py index 09659f56..e1e9e8a6 100644 --- a/jedi/api/helpers.py +++ b/jedi/api/helpers.py @@ -97,7 +97,11 @@ def _get_code_for_stack(code_lines, module_node, position): if leaf == ';': user_stmt = leaf.parent else: - user_stmt = leaf.get_definition() + user_stmt = leaf + while True: + if user_stmt.parent.type in ('file_input', 'suite'): + break + user_stmt = user_stmt.parent if user_stmt.parent.type == 'simple_stmt': user_stmt = user_stmt.parent