Path 1: 5064 calls (0.9)

FunctionDef (3185) ClassDef (1260) For (519) While (100)

None (5064)

1def visit_functiondef(
2        self, node: nodes.FunctionDef | nodes.While | nodes.For | nodes.ClassDef
3    ) -> None:
4        # If it is the first non import instruction of the module, record it.
5        if self._first_non_import_node:
6            return
7
8        # Check if the node belongs to an `If` or a `Try` block. If they
9        # contain imports, skip recording this node.
10        if not isinstance(node.parent.scope(), nodes.Module):
11            return
12
13        root = node
14        while not isinstance(root.parent, nodes.Module):
15            root = root.parent
16
17        if isinstance(root, (nodes.If, nodes.TryFinally, nodes.TryExcept)):
18            if any(root.nodes_of_class((nodes.Import, nodes.ImportFrom))):
19                return
20
21        self._first_non_import_node = node
            

Path 2: 552 calls (0.1)

FunctionDef (285) ClassDef (260) While (4) For (3)

1def visit_functiondef(
2        self, node: nodes.FunctionDef | nodes.While | nodes.For | nodes.ClassDef
3    ) -> None:
4        # If it is the first non import instruction of the module, record it.
5        if self._first_non_import_node:
6            return
7
8        # Check if the node belongs to an `If` or a `Try` block. If they
9        # contain imports, skip recording this node.
10        if not isinstance(node.parent.scope(), nodes.Module):
11            return
12
13        root = node
14        while not isinstance(root.parent, nodes.Module):
15            root = root.parent
16
17        if isinstance(root, (nodes.If, nodes.TryFinally, nodes.TryExcept)):
18            if any(root.nodes_of_class((nodes.Import, nodes.ImportFrom))):
19                return
20
21        self._first_non_import_node = node
            

Path 3: 2 calls (0.0)

For (1) FunctionDef (1)

None (2)

1def visit_functiondef(
2        self, node: nodes.FunctionDef | nodes.While | nodes.For | nodes.ClassDef
3    ) -> None:
4        # If it is the first non import instruction of the module, record it.
5        if self._first_non_import_node:
6            return
7
8        # Check if the node belongs to an `If` or a `Try` block. If they
9        # contain imports, skip recording this node.
10        if not isinstance(node.parent.scope(), nodes.Module):
11            return
12
13        root = node
14        while not isinstance(root.parent, nodes.Module):
15            root = root.parent
16
17        if isinstance(root, (nodes.If, nodes.TryFinally, nodes.TryExcept)):
18            if any(root.nodes_of_class((nodes.Import, nodes.ImportFrom))):
19                return
20
21        self._first_non_import_node = node
            

Path 4: 1 calls (0.0)

FunctionDef (1)

None (1)

1def visit_functiondef(
2        self, node: nodes.FunctionDef | nodes.While | nodes.For | nodes.ClassDef
3    ) -> None:
4        # If it is the first non import instruction of the module, record it.
5        if self._first_non_import_node:
6            return
7
8        # Check if the node belongs to an `If` or a `Try` block. If they
9        # contain imports, skip recording this node.
10        if not isinstance(node.parent.scope(), nodes.Module):
11            return
12
13        root = node
14        while not isinstance(root.parent, nodes.Module):
15            root = root.parent
16
17        if isinstance(root, (nodes.If, nodes.TryFinally, nodes.TryExcept)):
18            if any(root.nodes_of_class((nodes.Import, nodes.ImportFrom))):
19                return
20
21        self._first_non_import_node = node