Path 1: 12 calls (0.55)

Assign (12)

None (12)

1@only_required_for_messages("dict-init-mutate")
2    def visit_assign(self, node: nodes.Assign) -> None:
3        """
4        Detect dictionary mutation immediately after initialization.
5
6        At this time, detecting nested mutation is not supported.
7        """
8        if not isinstance(node.value, nodes.Dict):
9            return
10
11        dict_name = node.targets[0]
12        if len(node.targets) != 1 or not isinstance(dict_name, nodes.AssignName):
13            return
14
15        first_sibling = node.next_sibling()
16        if (
17            not first_sibling
18            or not isinstance(first_sibling, nodes.Assign)
19            or len(first_sibling.targets) != 1
20        ):
21            return
22
23        sibling_target = first_sibling.targets[0]
24        if not isinstance(sibling_target, nodes.Subscript):
25            return
26
27        sibling_name = sibling_target.value
28        if not isinstance(sibling_name, nodes.Name):
29            return
30
31        if sibling_name.name == dict_name.name:
32            self.add_message("dict-init-mutate", node=node, confidence=HIGH)
            

Path 2: 4 calls (0.18)

Assign (4)

None (4)

1@only_required_for_messages("dict-init-mutate")
2    def visit_assign(self, node: nodes.Assign) -> None:
3        """
4        Detect dictionary mutation immediately after initialization.
5
6        At this time, detecting nested mutation is not supported.
7        """
8        if not isinstance(node.value, nodes.Dict):
9            return
10
11        dict_name = node.targets[0]
12        if len(node.targets) != 1 or not isinstance(dict_name, nodes.AssignName):
13            return
14
15        first_sibling = node.next_sibling()
16        if (
17            not first_sibling
18            or not isinstance(first_sibling, nodes.Assign)
19            or len(first_sibling.targets) != 1
20        ):
21            return
22
23        sibling_target = first_sibling.targets[0]
24        if not isinstance(sibling_target, nodes.Subscript):
25            return
26
27        sibling_name = sibling_target.value
28        if not isinstance(sibling_name, nodes.Name):
29            return
30
31        if sibling_name.name == dict_name.name:
32            self.add_message("dict-init-mutate", node=node, confidence=HIGH)
            

Path 3: 3 calls (0.14)

Assign (3)

1@only_required_for_messages("dict-init-mutate")
2    def visit_assign(self, node: nodes.Assign) -> None:
3        """
4        Detect dictionary mutation immediately after initialization.
5
6        At this time, detecting nested mutation is not supported.
7        """
8        if not isinstance(node.value, nodes.Dict):
9            return
10
11        dict_name = node.targets[0]
12        if len(node.targets) != 1 or not isinstance(dict_name, nodes.AssignName):
13            return
14
15        first_sibling = node.next_sibling()
16        if (
17            not first_sibling
18            or not isinstance(first_sibling, nodes.Assign)
19            or len(first_sibling.targets) != 1
20        ):
21            return
22
23        sibling_target = first_sibling.targets[0]
24        if not isinstance(sibling_target, nodes.Subscript):
25            return
26
27        sibling_name = sibling_target.value
28        if not isinstance(sibling_name, nodes.Name):
29            return
30
31        if sibling_name.name == dict_name.name:
32            self.add_message("dict-init-mutate", node=node, confidence=HIGH)
            

Path 4: 1 calls (0.05)

Assign (1)

None (1)

1@only_required_for_messages("dict-init-mutate")
2    def visit_assign(self, node: nodes.Assign) -> None:
3        """
4        Detect dictionary mutation immediately after initialization.
5
6        At this time, detecting nested mutation is not supported.
7        """
8        if not isinstance(node.value, nodes.Dict):
9            return
10
11        dict_name = node.targets[0]
12        if len(node.targets) != 1 or not isinstance(dict_name, nodes.AssignName):
13            return
14
15        first_sibling = node.next_sibling()
16        if (
17            not first_sibling
18            or not isinstance(first_sibling, nodes.Assign)
19            or len(first_sibling.targets) != 1
20        ):
21            return
22
23        sibling_target = first_sibling.targets[0]
24        if not isinstance(sibling_target, nodes.Subscript):
25            return
26
27        sibling_name = sibling_target.value
28        if not isinstance(sibling_name, nodes.Name):
29            return
30
31        if sibling_name.name == dict_name.name:
32            self.add_message("dict-init-mutate", node=node, confidence=HIGH)
            

Path 5: 1 calls (0.05)

Assign (1)

None (1)

1@only_required_for_messages("dict-init-mutate")
2    def visit_assign(self, node: nodes.Assign) -> None:
3        """
4        Detect dictionary mutation immediately after initialization.
5
6        At this time, detecting nested mutation is not supported.
7        """
8        if not isinstance(node.value, nodes.Dict):
9            return
10
11        dict_name = node.targets[0]
12        if len(node.targets) != 1 or not isinstance(dict_name, nodes.AssignName):
13            return
14
15        first_sibling = node.next_sibling()
16        if (
17            not first_sibling
18            or not isinstance(first_sibling, nodes.Assign)
19            or len(first_sibling.targets) != 1
20        ):
21            return
22
23        sibling_target = first_sibling.targets[0]
24        if not isinstance(sibling_target, nodes.Subscript):
25            return
26
27        sibling_name = sibling_target.value
28        if not isinstance(sibling_name, nodes.Name):
29            return
30
31        if sibling_name.name == dict_name.name:
32            self.add_message("dict-init-mutate", node=node, confidence=HIGH)
            

Path 6: 1 calls (0.05)

Assign (1)

None (1)

1@only_required_for_messages("dict-init-mutate")
2    def visit_assign(self, node: nodes.Assign) -> None:
3        """
4        Detect dictionary mutation immediately after initialization.
5
6        At this time, detecting nested mutation is not supported.
7        """
8        if not isinstance(node.value, nodes.Dict):
9            return
10
11        dict_name = node.targets[0]
12        if len(node.targets) != 1 or not isinstance(dict_name, nodes.AssignName):
13            return
14
15        first_sibling = node.next_sibling()
16        if (
17            not first_sibling
18            or not isinstance(first_sibling, nodes.Assign)
19            or len(first_sibling.targets) != 1
20        ):
21            return
22
23        sibling_target = first_sibling.targets[0]
24        if not isinstance(sibling_target, nodes.Subscript):
25            return
26
27        sibling_name = sibling_target.value
28        if not isinstance(sibling_name, nodes.Name):
29            return
30
31        if sibling_name.name == dict_name.name:
32            self.add_message("dict-init-mutate", node=node, confidence=HIGH)