Path 1: 3938 calls (0.7)

Call (3938)

None (3938)

1def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
2        if not isinstance(node.func, nodes.Attribute):
3            return
4        if node.func.attrname != "keys":
5            return
6
7        if isinstance(node.parent, nodes.BinOp) and node.parent.op in {"&", "|", "^"}:
8            return
9
10        comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
11        if (
12            isinstance(node.parent, (nodes.For, nodes.Comprehension))
13            or comp_ancestor
14            and any(
15                op
16                for op, comparator in comp_ancestor.ops
17                if op in {"in", "not in"}
18                and (comparator in node.node_ancestors() or comparator is node)
19            )
20        ):
21            inferred = utils.safe_infer(node.func)
22            if not isinstance(inferred, astroid.BoundMethod) or not isinstance(
23                inferred.bound, nodes.Dict
24            ):
25                return
26            self.add_message(
27                "consider-iterating-dictionary", node=node, confidence=INFERENCE
28            )
            

Path 2: 1637 calls (0.29)

Call (1637)

None (1637)

1def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
2        if not isinstance(node.func, nodes.Attribute):
3            return
4        if node.func.attrname != "keys":
5            return
6
7        if isinstance(node.parent, nodes.BinOp) and node.parent.op in {"&", "|", "^"}:
8            return
9
10        comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
11        if (
12            isinstance(node.parent, (nodes.For, nodes.Comprehension))
13            or comp_ancestor
14            and any(
15                op
16                for op, comparator in comp_ancestor.ops
17                if op in {"in", "not in"}
18                and (comparator in node.node_ancestors() or comparator is node)
19            )
20        ):
21            inferred = utils.safe_infer(node.func)
22            if not isinstance(inferred, astroid.BoundMethod) or not isinstance(
23                inferred.bound, nodes.Dict
24            ):
25                return
26            self.add_message(
27                "consider-iterating-dictionary", node=node, confidence=INFERENCE
28            )
            

Path 3: 20 calls (0.0)

Call (20)

1def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
2        if not isinstance(node.func, nodes.Attribute):
3            return
4        if node.func.attrname != "keys":
5            return
6
7        if isinstance(node.parent, nodes.BinOp) and node.parent.op in {"&", "|", "^"}:
8            return
9
10        comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
11        if (
12            isinstance(node.parent, (nodes.For, nodes.Comprehension))
13            or comp_ancestor
14            and any(
15                op
16                for op, comparator in comp_ancestor.ops
17                if op in {"in", "not in"}
18                and (comparator in node.node_ancestors() or comparator is node)
19            )
20        ):
21            inferred = utils.safe_infer(node.func)
22            if not isinstance(inferred, astroid.BoundMethod) or not isinstance(
23                inferred.bound, nodes.Dict
24            ):
25                return
26            self.add_message(
27                "consider-iterating-dictionary", node=node, confidence=INFERENCE
28            )
            

Path 4: 13 calls (0.0)

Call (13)

GeneratorExit (13)

1def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
2        if not isinstance(node.func, nodes.Attribute):
3            return
4        if node.func.attrname != "keys":
5            return
6
7        if isinstance(node.parent, nodes.BinOp) and node.parent.op in {"&", "|", "^"}:
8            return
9
10        comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
11        if (
12            isinstance(node.parent, (nodes.For, nodes.Comprehension))
13            or comp_ancestor
14            and any(
15                op
16                for op, comparator in comp_ancestor.ops
17                if op in {"in", "not in"}
18                and (comparator in node.node_ancestors() or comparator is node)
19            )
20        ):
21            inferred = utils.safe_infer(node.func)
22            if not isinstance(inferred, astroid.BoundMethod) or not isinstance(
23                inferred.bound, nodes.Dict
24            ):
25                return
26            self.add_message(
27                "consider-iterating-dictionary", node=node, confidence=INFERENCE
28            )
            

Path 5: 5 calls (0.0)

Call (5)

1def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
2        if not isinstance(node.func, nodes.Attribute):
3            return
4        if node.func.attrname != "keys":
5            return
6
7        if isinstance(node.parent, nodes.BinOp) and node.parent.op in {"&", "|", "^"}:
8            return
9
10        comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
11        if (
12            isinstance(node.parent, (nodes.For, nodes.Comprehension))
13            or comp_ancestor
14            and any(
15                op
16                for op, comparator in comp_ancestor.ops
17                if op in {"in", "not in"}
18                and (comparator in node.node_ancestors() or comparator is node)
19            )
20        ):
21            inferred = utils.safe_infer(node.func)
22            if not isinstance(inferred, astroid.BoundMethod) or not isinstance(
23                inferred.bound, nodes.Dict
24            ):
25                return
26            self.add_message(
27                "consider-iterating-dictionary", node=node, confidence=INFERENCE
28            )
            

Path 6: 4 calls (0.0)

Call (4)

None (4)

1def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
2        if not isinstance(node.func, nodes.Attribute):
3            return
4        if node.func.attrname != "keys":
5            return
6
7        if isinstance(node.parent, nodes.BinOp) and node.parent.op in {"&", "|", "^"}:
8            return
9
10        comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
11        if (
12            isinstance(node.parent, (nodes.For, nodes.Comprehension))
13            or comp_ancestor
14            and any(
15                op
16                for op, comparator in comp_ancestor.ops
17                if op in {"in", "not in"}
18                and (comparator in node.node_ancestors() or comparator is node)
19            )
20        ):
21            inferred = utils.safe_infer(node.func)
22            if not isinstance(inferred, astroid.BoundMethod) or not isinstance(
23                inferred.bound, nodes.Dict
24            ):
25                return
26            self.add_message(
27                "consider-iterating-dictionary", node=node, confidence=INFERENCE
28            )
            

Path 7: 3 calls (0.0)

Call (3)

None (3)

1def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
2        if not isinstance(node.func, nodes.Attribute):
3            return
4        if node.func.attrname != "keys":
5            return
6
7        if isinstance(node.parent, nodes.BinOp) and node.parent.op in {"&", "|", "^"}:
8            return
9
10        comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
11        if (
12            isinstance(node.parent, (nodes.For, nodes.Comprehension))
13            or comp_ancestor
14            and any(
15                op
16                for op, comparator in comp_ancestor.ops
17                if op in {"in", "not in"}
18                and (comparator in node.node_ancestors() or comparator is node)
19            )
20        ):
21            inferred = utils.safe_infer(node.func)
22            if not isinstance(inferred, astroid.BoundMethod) or not isinstance(
23                inferred.bound, nodes.Dict
24            ):
25                return
26            self.add_message(
27                "consider-iterating-dictionary", node=node, confidence=INFERENCE
28            )
            

Path 8: 2 calls (0.0)

Call (2)

None (2)

GeneratorExit (2)

1def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
2        if not isinstance(node.func, nodes.Attribute):
3            return
4        if node.func.attrname != "keys":
5            return
6
7        if isinstance(node.parent, nodes.BinOp) and node.parent.op in {"&", "|", "^"}:
8            return
9
10        comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
11        if (
12            isinstance(node.parent, (nodes.For, nodes.Comprehension))
13            or comp_ancestor
14            and any(
15                op
16                for op, comparator in comp_ancestor.ops
17                if op in {"in", "not in"}
18                and (comparator in node.node_ancestors() or comparator is node)
19            )
20        ):
21            inferred = utils.safe_infer(node.func)
22            if not isinstance(inferred, astroid.BoundMethod) or not isinstance(
23                inferred.bound, nodes.Dict
24            ):
25                return
26            self.add_message(
27                "consider-iterating-dictionary", node=node, confidence=INFERENCE
28            )
            

Path 9: 2 calls (0.0)

Call (2)

1def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
2        if not isinstance(node.func, nodes.Attribute):
3            return
4        if node.func.attrname != "keys":
5            return
6
7        if isinstance(node.parent, nodes.BinOp) and node.parent.op in {"&", "|", "^"}:
8            return
9
10        comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
11        if (
12            isinstance(node.parent, (nodes.For, nodes.Comprehension))
13            or comp_ancestor
14            and any(
15                op
16                for op, comparator in comp_ancestor.ops
17                if op in {"in", "not in"}
18                and (comparator in node.node_ancestors() or comparator is node)
19            )
20        ):
21            inferred = utils.safe_infer(node.func)
22            if not isinstance(inferred, astroid.BoundMethod) or not isinstance(
23                inferred.bound, nodes.Dict
24            ):
25                return
26            self.add_message(
27                "consider-iterating-dictionary", node=node, confidence=INFERENCE
28            )
            

Path 10: 1 calls (0.0)

Call (1)

None (1)

1def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
2        if not isinstance(node.func, nodes.Attribute):
3            return
4        if node.func.attrname != "keys":
5            return
6
7        if isinstance(node.parent, nodes.BinOp) and node.parent.op in {"&", "|", "^"}:
8            return
9
10        comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
11        if (
12            isinstance(node.parent, (nodes.For, nodes.Comprehension))
13            or comp_ancestor
14            and any(
15                op
16                for op, comparator in comp_ancestor.ops
17                if op in {"in", "not in"}
18                and (comparator in node.node_ancestors() or comparator is node)
19            )
20        ):
21            inferred = utils.safe_infer(node.func)
22            if not isinstance(inferred, astroid.BoundMethod) or not isinstance(
23                inferred.bound, nodes.Dict
24            ):
25                return
26            self.add_message(
27                "consider-iterating-dictionary", node=node, confidence=INFERENCE
28            )
            

Path 11: 1 calls (0.0)

Call (1)

None (1)

GeneratorExit (1)

1def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
2        if not isinstance(node.func, nodes.Attribute):
3            return
4        if node.func.attrname != "keys":
5            return
6
7        if isinstance(node.parent, nodes.BinOp) and node.parent.op in {"&", "|", "^"}:
8            return
9
10        comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
11        if (
12            isinstance(node.parent, (nodes.For, nodes.Comprehension))
13            or comp_ancestor
14            and any(
15                op
16                for op, comparator in comp_ancestor.ops
17                if op in {"in", "not in"}
18                and (comparator in node.node_ancestors() or comparator is node)
19            )
20        ):
21            inferred = utils.safe_infer(node.func)
22            if not isinstance(inferred, astroid.BoundMethod) or not isinstance(
23                inferred.bound, nodes.Dict
24            ):
25                return
26            self.add_message(
27                "consider-iterating-dictionary", node=node, confidence=INFERENCE
28            )