diff --git a/jedi/evaluate/flow_analysis.py b/jedi/evaluate/flow_analysis.py index 3a0c03d5..06de185a 100644 --- a/jedi/evaluate/flow_analysis.py +++ b/jedi/evaluate/flow_analysis.py @@ -84,7 +84,7 @@ def _break_check(context, context_scope, flow_scope, node): break reachable = reachable.invert() else: - flow_node = flow_scope.in_which_test_node(node) + flow_node = flow_scope.get_corresponding_test_node(node) if flow_node is not None: reachable = _check_if(context, flow_node) elif flow_scope.type in ('try_stmt', 'while_stmt'): diff --git a/jedi/parser/python/tree.py b/jedi/parser/python/tree.py index a409f948..16e647c3 100644 --- a/jedi/parser/python/tree.py +++ b/jedi/parser/python/tree.py @@ -693,11 +693,11 @@ class IfStmt(Flow): if c in ('elif', 'if'): yield self.children[i + 1] - def in_which_test_node(self, node): + def get_corresponding_test_node(self, node): """ - Returns the test node (see function above) that a node is contained - in. However if the node is in the test node itself and not in the - suite return None. + Searches for the branch in which the node is and returns the + corresponding test node (see function above). However if the node is in + the test node itself and not in the suite return None. """ start_pos = node.start_pos for check_node in reversed(list(self.get_test_nodes())):