Method: pylint.checkers.utils.find_try_except_wrapper_node
Calls: 2411, Exceptions: 0, Paths: 3Back
Path 1: 2238 calls (0.93)
ImportFrom (860) Import (818) Name (228) Attribute (195) Raise (122) AssignName (6) Call (4) DelName (4) DelAttr (1)
None (2238)
1def find_try_except_wrapper_node(
2 node: nodes.NodeNG,
3) -> nodes.ExceptHandler | nodes.TryExcept | None:
4 """Return the ExceptHandler or the TryExcept node in which the node is."""
5 current = node
6 ignores = (nodes.ExceptHandler, nodes.TryExcept)
7 while current and not isinstance(current.parent, ignores):
8 current = current.parent
9
10 if current and isinstance(current.parent, ignores):
11 return current.parent
12 return None
Path 2: 106 calls (0.04)
Import (52) Raise (31) ImportFrom (19) Name (3) Attribute (1)
TryExcept (72) ExceptHandler (34)
1def find_try_except_wrapper_node(
2 node: nodes.NodeNG,
3) -> nodes.ExceptHandler | nodes.TryExcept | None:
4 """Return the ExceptHandler or the TryExcept node in which the node is."""
5 current = node
6 ignores = (nodes.ExceptHandler, nodes.TryExcept)
7 while current and not isinstance(current.parent, ignores):
8 current = current.parent
9
10 if current and isinstance(current.parent, ignores):
11 return current.parent
12 return None
Path 3: 67 calls (0.03)
Name (32) Raise (11) Attribute (11) Import (5) Call (4) BinOp (4)
TryExcept (41) ExceptHandler (26)
1def find_try_except_wrapper_node(
2 node: nodes.NodeNG,
3) -> nodes.ExceptHandler | nodes.TryExcept | None:
4 """Return the ExceptHandler or the TryExcept node in which the node is."""
5 current = node
6 ignores = (nodes.ExceptHandler, nodes.TryExcept)
7 while current and not isinstance(current.parent, ignores):
8 current = current.parent
9
10 if current and isinstance(current.parent, ignores):
11 return current.parent
12 return None