Path 1: 826 calls (0.93)

Name (253) Attribute (199) Import (123) ImportFrom (121) Raise (115) AssignName (6) Call (4) DelName (4) DelAttr (1)

NameError def (263) ImportError def (244) AttributeError def (200) 'RuntimeError' (41) 'NameError' (23) 'error' (18) StopIteration def (10) 'ValueErro...

[] (826)

1def get_exception_handlers(
2    node: nodes.NodeNG, exception: type[Exception] | str = Exception
3) -> list[nodes.ExceptHandler] | None:
4    """Return the collections of handlers handling the exception in arguments.
5
6    Args:
7        node (nodes.NodeNG): A node that is potentially wrapped in a try except.
8        exception (builtin.Exception or str): exception or name of the exception.
9
10    Returns:
11        list: the collection of handlers that are handling the exception or None.
12    """
13    context = find_try_except_wrapper_node(node)
14    if isinstance(context, nodes.TryExcept):
15        return [
16            handler for handler in context.handlers if error_of_type(handler, exception)
17        ]
18    return []
            

Path 2: 60 calls (0.07)

Import (19) Raise (13) Name (10) Attribute (8) Call (4) BinOp (4) ImportFrom (2)

ImportError def (21) NameError def (10) AttributeError def (8) 'ValueError' (6) 'RuntimeError' (4) StopIteration def (4) ZeroDivisionError def (4) 'ty...

list (34) [] (26)

1def get_exception_handlers(
2    node: nodes.NodeNG, exception: type[Exception] | str = Exception
3) -> list[nodes.ExceptHandler] | None:
4    """Return the collections of handlers handling the exception in arguments.
5
6    Args:
7        node (nodes.NodeNG): A node that is potentially wrapped in a try except.
8        exception (builtin.Exception or str): exception or name of the exception.
9
10    Returns:
11        list: the collection of handlers that are handling the exception or None.
12    """
13    context = find_try_except_wrapper_node(node)
14    if isinstance(context, nodes.TryExcept):
15        return [
16            handler for handler in context.handlers if error_of_type(handler, exception)
17        ]
18    return []