Method: pylint.checkers.base.basic_checker.BasicChecker._check_not_in_finally
Calls: 1751, Exceptions: 0, Paths: 5Back
Path 1: 1737 calls (0.99)
Return (1608) Break (129)
'return' (1608) 'break' (129)
tuple (1737)
None (1737)
1def _check_not_in_finally(
2 self,
3 node: nodes.Break | nodes.Return,
4 node_name: str,
5 breaker_classes: tuple[nodes.NodeNG, ...] = (),
6 ) -> None:
7 """Check that a node is not inside a 'finally' clause of a
8 'try...finally' statement.
9
10 If we find a parent which type is in breaker_classes before
11 a 'try...finally' block we skip the whole check.
12 """
13 # if self._tryfinallys is empty, we're not an in try...finally block
14 if not self._tryfinallys:
15 return
16 # the node could be a grand-grand...-child of the 'try...finally'
17 _parent = node.parent
18 _node = node
19 while _parent and not isinstance(_parent, breaker_classes):
20 if hasattr(_parent, "finalbody") and _node in _parent.finalbody:
21 self.add_message("lost-exception", node=node, args=node_name)
22 return
23 _node = _parent
24 _parent = _node.parent
Path 2: 10 calls (0.01)
Return (8) Break (2)
'return' (8) 'break' (2)
tuple (10)
1def _check_not_in_finally(
2 self,
3 node: nodes.Break | nodes.Return,
4 node_name: str,
5 breaker_classes: tuple[nodes.NodeNG, ...] = (),
6 ) -> None:
7 """Check that a node is not inside a 'finally' clause of a
8 'try...finally' statement.
9
10 If we find a parent which type is in breaker_classes before
11 a 'try...finally' block we skip the whole check.
12 """
13 # if self._tryfinallys is empty, we're not an in try...finally block
14 if not self._tryfinallys:
15 return
16 # the node could be a grand-grand...-child of the 'try...finally'
17 _parent = node.parent
18 _node = node
19 while _parent and not isinstance(_parent, breaker_classes):
20 if hasattr(_parent, "finalbody") and _node in _parent.finalbody:
21 self.add_message("lost-exception", node=node, args=node_name)
22 return
23 _node = _parent
24 _parent = _node.parent
Path 3: 2 calls (0.0)
Break (1) Return (1)
'break' (1) 'return' (1)
tuple (2)
None (2)
1def _check_not_in_finally(
2 self,
3 node: nodes.Break | nodes.Return,
4 node_name: str,
5 breaker_classes: tuple[nodes.NodeNG, ...] = (),
6 ) -> None:
7 """Check that a node is not inside a 'finally' clause of a
8 'try...finally' statement.
9
10 If we find a parent which type is in breaker_classes before
11 a 'try...finally' block we skip the whole check.
12 """
13 # if self._tryfinallys is empty, we're not an in try...finally block
14 if not self._tryfinallys:
15 return
16 # the node could be a grand-grand...-child of the 'try...finally'
17 _parent = node.parent
18 _node = node
19 while _parent and not isinstance(_parent, breaker_classes):
20 if hasattr(_parent, "finalbody") and _node in _parent.finalbody:
21 self.add_message("lost-exception", node=node, args=node_name)
22 return
23 _node = _parent
24 _parent = _node.parent
Path 4: 1 calls (0.0)
Break (1)
'break' (1)
tuple (1)
None (1)
1def _check_not_in_finally(
2 self,
3 node: nodes.Break | nodes.Return,
4 node_name: str,
5 breaker_classes: tuple[nodes.NodeNG, ...] = (),
6 ) -> None:
7 """Check that a node is not inside a 'finally' clause of a
8 'try...finally' statement.
9
10 If we find a parent which type is in breaker_classes before
11 a 'try...finally' block we skip the whole check.
12 """
13 # if self._tryfinallys is empty, we're not an in try...finally block
14 if not self._tryfinallys:
15 return
16 # the node could be a grand-grand...-child of the 'try...finally'
17 _parent = node.parent
18 _node = node
19 while _parent and not isinstance(_parent, breaker_classes):
20 if hasattr(_parent, "finalbody") and _node in _parent.finalbody:
21 self.add_message("lost-exception", node=node, args=node_name)
22 return
23 _node = _parent
24 _parent = _node.parent
Path 5: 1 calls (0.0)
Return (1)
'return' (1)
tuple (1)
1def _check_not_in_finally(
2 self,
3 node: nodes.Break | nodes.Return,
4 node_name: str,
5 breaker_classes: tuple[nodes.NodeNG, ...] = (),
6 ) -> None:
7 """Check that a node is not inside a 'finally' clause of a
8 'try...finally' statement.
9
10 If we find a parent which type is in breaker_classes before
11 a 'try...finally' block we skip the whole check.
12 """
13 # if self._tryfinallys is empty, we're not an in try...finally block
14 if not self._tryfinallys:
15 return
16 # the node could be a grand-grand...-child of the 'try...finally'
17 _parent = node.parent
18 _node = node
19 while _parent and not isinstance(_parent, breaker_classes):
20 if hasattr(_parent, "finalbody") and _node in _parent.finalbody:
21 self.add_message("lost-exception", node=node, args=node_name)
22 return
23 _node = _parent
24 _parent = _node.parent