Skip to content

Commit

Permalink
Use a list to hold the statements to be filtered per node instead of …
Browse files Browse the repository at this point in the history
…keeping them in a dict
  • Loading branch information
PCManticore committed Mar 8, 2019
1 parent f8155a0 commit f33c5a0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions astroid/node_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,13 +1097,15 @@ def ilookup(self, name):
return bases._infer_stmts(stmts, context, frame)

def _get_filtered_node_statements(self, nodes):
statements = {node: node.statement() for node in nodes}
statements = [(node, node.statement()) for node in nodes]
# Next we check if we have ExceptHandlers that are parent
# of the underlying variable, in which case the last one survives
if all(isinstance(stmt, ExceptHandler) for stmt in statements.values()):
statements = {
node: stmt for node, stmt in statements.items() if stmt.parent_of(self)
}
if len(statements) > 1 and all(
isinstance(stmt, ExceptHandler) for _, stmt in statements
):
statements = [
(node, stmt) for node, stmt in statements if stmt.parent_of(self)
]
return statements

def _filter_stmts(self, stmts, frame, offset):
Expand Down Expand Up @@ -1164,7 +1166,7 @@ def _filter_stmts(self, stmts, frame, offset):
_stmt_parents = []
statements = self._get_filtered_node_statements(stmts)

for node, stmt in statements.items():
for node, stmt in statements:
# line filtering is on and we have reached our location, break
if stmt.fromlineno > mylineno > 0:
break
Expand Down

0 comments on commit f33c5a0

Please sign in to comment.