mirror of
https://github.com/davidhalter/jedi.git
synced 2026-09-17 03:13:13 +08:00
More tests and better understanding of if/try branches name resolution.
This commit is contained in:
@@ -155,13 +155,18 @@ class ParserTreeFilter(AbstractUsedNamesFilter):
|
||||
|
||||
def _filter(self, names):
|
||||
names = super(ParserTreeFilter, self)._filter(names)
|
||||
names = [n for n in names if n.is_definition() and n.parent.type != 'trailer']
|
||||
names = [n for n in names
|
||||
if ((n.parent if n.parent.type in ('classdef', 'funcdef') else n)
|
||||
.get_parent_scope() == self._parser_scope)]
|
||||
|
||||
names = [n for n in names if self._is_name_reachable(n)]
|
||||
return list(self._check_flows(names))
|
||||
|
||||
def _is_name_reachable(self, name):
|
||||
if not name.is_definition():
|
||||
return False
|
||||
parent = name.parent
|
||||
if parent.type == 'trailer':
|
||||
return False
|
||||
base_node = parent if parent.type in ('classdef', 'funcdef') else name
|
||||
return base_node.get_parent_scope() == self._parser_scope
|
||||
|
||||
def _check_flows(self, names):
|
||||
for name in sorted(names, key=lambda name: name.start_pos, reverse=True):
|
||||
check = flow_analysis.reachability_check(
|
||||
|
||||
Reference in New Issue
Block a user