Path 1: 3127 calls (0.68)

Call (1573) FunctionDef (1067) Attribute (399) AssignAttr (45) UnboundMethod (26) AsyncFunctionDef (12) Property (5)

ClassDef (3127)

1def node_frame_class(node: nodes.NodeNG) -> nodes.ClassDef | None:
2    """Return the class that is wrapping the given node.
3
4    The function returns a class for a method node (or a staticmethod or a
5    classmethod), otherwise it returns `None`.
6    """
7    klass = node.frame(future=True)
8    nodes_to_check = (
9        nodes.NodeNG,
10        astroid.UnboundMethod,
11        astroid.BaseInstance,
12    )
13    while (
14        klass
15        and isinstance(klass, nodes_to_check)
16        and not isinstance(klass, nodes.ClassDef)
17    ):
18        if klass.parent is None:
19            return None
20
21        klass = klass.parent.frame(future=True)
22
23    return klass
            

Path 2: 724 calls (0.16)

Call (718) Attribute (4) AssignAttr (2)

None (724)

1def node_frame_class(node: nodes.NodeNG) -> nodes.ClassDef | None:
2    """Return the class that is wrapping the given node.
3
4    The function returns a class for a method node (or a staticmethod or a
5    classmethod), otherwise it returns `None`.
6    """
7    klass = node.frame(future=True)
8    nodes_to_check = (
9        nodes.NodeNG,
10        astroid.UnboundMethod,
11        astroid.BaseInstance,
12    )
13    while (
14        klass
15        and isinstance(klass, nodes_to_check)
16        and not isinstance(klass, nodes.ClassDef)
17    ):
18        if klass.parent is None:
19            return None
20
21        klass = klass.parent.frame(future=True)
22
23    return klass
            

Path 3: 693 calls (0.15)

Call (687) Attribute (3) UnboundMethod (2) FunctionDef (1)

None (693)

1def node_frame_class(node: nodes.NodeNG) -> nodes.ClassDef | None:
2    """Return the class that is wrapping the given node.
3
4    The function returns a class for a method node (or a staticmethod or a
5    classmethod), otherwise it returns `None`.
6    """
7    klass = node.frame(future=True)
8    nodes_to_check = (
9        nodes.NodeNG,
10        astroid.UnboundMethod,
11        astroid.BaseInstance,
12    )
13    while (
14        klass
15        and isinstance(klass, nodes_to_check)
16        and not isinstance(klass, nodes.ClassDef)
17    ):
18        if klass.parent is None:
19            return None
20
21        klass = klass.parent.frame(future=True)
22
23    return klass
            

Path 4: 47 calls (0.01)

Call (47)

ClassDef (47)

1def node_frame_class(node: nodes.NodeNG) -> nodes.ClassDef | None:
2    """Return the class that is wrapping the given node.
3
4    The function returns a class for a method node (or a staticmethod or a
5    classmethod), otherwise it returns `None`.
6    """
7    klass = node.frame(future=True)
8    nodes_to_check = (
9        nodes.NodeNG,
10        astroid.UnboundMethod,
11        astroid.BaseInstance,
12    )
13    while (
14        klass
15        and isinstance(klass, nodes_to_check)
16        and not isinstance(klass, nodes.ClassDef)
17    ):
18        if klass.parent is None:
19            return None
20
21        klass = klass.parent.frame(future=True)
22
23    return klass