Method: pylint.checkers.utils.find_except_wrapper_node_in_scope
Calls: 272, Exceptions: 0, Paths: 3Back
Path 1: 173 calls (0.64)
Raise (173)
None (173)
1def find_except_wrapper_node_in_scope(
2 node: nodes.NodeNG,
3) -> nodes.ExceptHandler | nodes.TryExcept | None:
4 """Return the ExceptHandler in which the node is, without going out of scope."""
5 for current in node.node_ancestors():
6 if isinstance(current, astroid.scoped_nodes.LocalsDictNodeNG):
7 # If we're inside a function/class definition, we don't want to keep checking
8 # higher ancestors for `except` clauses, because if these exist, it means our
9 # function/class was defined in an `except` clause, rather than the current code
10 # actually running in an `except` clause.
11 return None
12 if isinstance(current, nodes.ExceptHandler):
13 return current
14 return None
Path 2: 71 calls (0.26)
Raise (71)
None (71)
1def find_except_wrapper_node_in_scope(
2 node: nodes.NodeNG,
3) -> nodes.ExceptHandler | nodes.TryExcept | None:
4 """Return the ExceptHandler in which the node is, without going out of scope."""
5 for current in node.node_ancestors():
6 if isinstance(current, astroid.scoped_nodes.LocalsDictNodeNG):
7 # If we're inside a function/class definition, we don't want to keep checking
8 # higher ancestors for `except` clauses, because if these exist, it means our
9 # function/class was defined in an `except` clause, rather than the current code
10 # actually running in an `except` clause.
11 return None
12 if isinstance(current, nodes.ExceptHandler):
13 return current
14 return None
Path 3: 28 calls (0.1)
Raise (28)
ExceptHandler (28)
1def find_except_wrapper_node_in_scope(
2 node: nodes.NodeNG,
3) -> nodes.ExceptHandler | nodes.TryExcept | None:
4 """Return the ExceptHandler in which the node is, without going out of scope."""
5 for current in node.node_ancestors():
6 if isinstance(current, astroid.scoped_nodes.LocalsDictNodeNG):
7 # If we're inside a function/class definition, we don't want to keep checking
8 # higher ancestors for `except` clauses, because if these exist, it means our
9 # function/class was defined in an `except` clause, rather than the current code
10 # actually running in an `except` clause.
11 return None
12 if isinstance(current, nodes.ExceptHandler):
13 return current
14 return None