Path 1: 193 calls (0.61)

FunctionDef (193)

ClassDef (193)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 2: 47 calls (0.15)

FunctionDef (47)

ClassDef (47)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 3: 45 calls (0.14)

FunctionDef (45)

ClassDef (45)

None (45)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 4: 11 calls (0.03)

FunctionDef (11)

ClassDef (11)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 5: 6 calls (0.02)

FunctionDef (6)

ClassDef (6)

KeyError (6)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 6: 2 calls (0.01)

FunctionDef (2)

ClassDef (2)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 7: 2 calls (0.01)

FunctionDef (2)

ClassDef (2)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 8: 2 calls (0.01)

FunctionDef (2)

ClassDef (2)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 9: 2 calls (0.01)

FunctionDef (2)

ClassDef (2)

None (2)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 10: 2 calls (0.01)

FunctionDef (2)

ClassDef (2)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 11: 1 calls (0.0)

FunctionDef (1)

ClassDef (1)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 12: 1 calls (0.0)

FunctionDef (1)

ClassDef (1)

KeyError (1)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 13: 1 calls (0.0)

FunctionDef (1)

ClassDef (1)

InferenceError (1)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 14: 1 calls (0.0)

FunctionDef (1)

ClassDef (1)

KeyError (1)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 15: 1 calls (0.0)

FunctionDef (1)

ClassDef (1)

None (1)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 16: 1 calls (0.0)

FunctionDef (1)

ClassDef (1)

KeyError (1)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )
            

Path 17: 1 calls (0.0)

FunctionDef (1)

ClassDef (1)

None (1)

1def _check_init(self, node: nodes.FunctionDef, klass_node: nodes.ClassDef) -> None:
2        """Check that the __init__ method call super or ancestors'__init__
3        method (unless it is used for type hinting with `typing.overload`).
4        """
5        if not self.linter.is_message_enabled(
6            "super-init-not-called"
7        ) and not self.linter.is_message_enabled("non-parent-init-called"):
8            return
9        to_call = _ancestors_to_call(klass_node)
10        not_called_yet = dict(to_call)
11        parents_with_called_inits: set[bases.UnboundMethod] = set()
12        for stmt in node.nodes_of_class(nodes.Call):
13            expr = stmt.func
14            if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__":
15                continue
16            # skip the test if using super
17            if (
18                isinstance(expr.expr, nodes.Call)
19                and isinstance(expr.expr.func, nodes.Name)
20                and expr.expr.func.name == "super"
21            ):
22                return
23            # pylint: disable = too-many-try-statements
24            try:
25                for klass in expr.expr.infer():
26                    if klass is astroid.Uninferable:
27                        continue
28                    # The inferred klass can be super(), which was
29                    # assigned to a variable and the `__init__`
30                    # was called later.
31                    #
32                    # base = super()
33                    # base.__init__(...)
34
35                    if (
36                        isinstance(klass, astroid.Instance)
37                        and isinstance(klass._proxied, nodes.ClassDef)
38                        and is_builtin_object(klass._proxied)
39                        and klass._proxied.name == "super"
40                    ):
41                        return
42                    if isinstance(klass, astroid.objects.Super):
43                        return
44                    try:
45                        method = not_called_yet.pop(klass)
46                        # Record that the class' init has been called
47                        parents_with_called_inits.add(node_frame_class(method))
48                    except KeyError:
49                        if klass not in klass_node.ancestors(recurs=False):
50                            self.add_message(
51                                "non-parent-init-called", node=expr, args=klass.name
52                            )
53            except astroid.InferenceError:
54                continue
55        for klass, method in not_called_yet.items():
56            # Check if the init of the class that defines this init has already
57            # been called.
58            if node_frame_class(method) in parents_with_called_inits:
59                return
60
61            if utils.is_protocol_class(klass):
62                return
63
64            if decorated_with(node, ["typing.overload"]):
65                continue
66            self.add_message(
67                "super-init-not-called",
68                args=klass.name,
69                node=node,
70                confidence=INFERENCE,
71            )