Method: pylint.checkers.utils.get_contextlib_with_statements
Calls: 851, Exceptions: 6, Paths: 2Back
Path 1: 825 calls (0.97)
Name (243) Attribute (202) Import (123) ImportFrom (121) Raise (116) Call (6) AssignName (6) DelName (4) BinOp (3) DelAttr (1)
1def get_contextlib_with_statements(node: nodes.NodeNG) -> Iterator[nodes.With]:
2 """Get all contextlib.with statements in the ancestors of the given node."""
3 for with_node in node.node_ancestors():
4 if isinstance(with_node, nodes.With):
5 yield with_node
Path 2: 26 calls (0.03)
Name (19) Import (7)
With (28) None (6)
GeneratorExit (6)
1def get_contextlib_with_statements(node: nodes.NodeNG) -> Iterator[nodes.With]:
2 """Get all contextlib.with statements in the ancestors of the given node."""
3 for with_node in node.node_ancestors():
4 if isinstance(with_node, nodes.With):
5 yield with_node