From ab2eb570a81922546f7c870f2d3c34878a55f642 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sat, 24 Jul 2021 17:27:27 +0100 Subject: [PATCH] Use search_ancestor for a more robust search --- jedi/inference/star_args.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/jedi/inference/star_args.py b/jedi/inference/star_args.py index 0c3a9e53..71ea7093 100644 --- a/jedi/inference/star_args.py +++ b/jedi/inference/star_args.py @@ -12,6 +12,8 @@ The signature here for bar should be `bar(b, c)` instead of bar(*args). """ from inspect import Parameter +from parso import tree + from jedi.inference.utils import to_list from jedi.inference.names import ParamNameWrapper from jedi.inference.helpers import is_big_annoying_library @@ -26,11 +28,7 @@ def _iter_nodes_for_param(param_name): # tree rather than going via the execution context so that we're agnostic of # the specific scope we're evaluating within (i.e: module or function, # etc.). - # - .tree_name is a Name - # - .parent is a Param - # - .parent is a PythonNode(parameters) - # - .parent is the FunctionNode we want. - function_node = param_name.tree_name.parent.parent.parent + function_node = tree.search_ancestor(param_name.tree_name, 'funcdef', 'lambdef') module_node = function_node.get_root_node() start = function_node.children[-1].start_pos end = function_node.children[-1].end_pos