Path 1: 11 calls (0.73)

Compare (11)

1def _check_constants_comparison(self, node: nodes.Compare) -> None:
2        """
3        Magic values in any side of the comparison should be avoided,
4        Detects comparisons that `comparison-of-constants` core checker cannot detect.
5        """
6        const_operands = []
7        LEFT_OPERAND = 0
8        RIGHT_OPERAND = 1
9
10        left_operand = node.left
11        const_operands.append(isinstance(left_operand, nodes.Const))
12
13        right_operand = node.ops[0][1]
14        const_operands.append(isinstance(right_operand, nodes.Const))
15
16        if all(const_operands):
17            # `comparison-of-constants` avoided
18            return
19
20        operand_value = None
21        if const_operands[LEFT_OPERAND] and self._is_magic_value(left_operand):
22            operand_value = left_operand.value
23        elif const_operands[RIGHT_OPERAND] and self._is_magic_value(right_operand):
24            operand_value = right_operand.value
25        if operand_value is not None:
26            self.add_message(
27                "magic-value-comparison",
28                node=node,
29                args=(operand_value),
30                confidence=HIGH,
31            )
            

Path 2: 2 calls (0.13)

Compare (2)

1def _check_constants_comparison(self, node: nodes.Compare) -> None:
2        """
3        Magic values in any side of the comparison should be avoided,
4        Detects comparisons that `comparison-of-constants` core checker cannot detect.
5        """
6        const_operands = []
7        LEFT_OPERAND = 0
8        RIGHT_OPERAND = 1
9
10        left_operand = node.left
11        const_operands.append(isinstance(left_operand, nodes.Const))
12
13        right_operand = node.ops[0][1]
14        const_operands.append(isinstance(right_operand, nodes.Const))
15
16        if all(const_operands):
17            # `comparison-of-constants` avoided
18            return
19
20        operand_value = None
21        if const_operands[LEFT_OPERAND] and self._is_magic_value(left_operand):
22            operand_value = left_operand.value
23        elif const_operands[RIGHT_OPERAND] and self._is_magic_value(right_operand):
24            operand_value = right_operand.value
25        if operand_value is not None:
26            self.add_message(
27                "magic-value-comparison",
28                node=node,
29                args=(operand_value),
30                confidence=HIGH,
31            )
            

Path 3: 1 calls (0.07)

Compare (1)

1def _check_constants_comparison(self, node: nodes.Compare) -> None:
2        """
3        Magic values in any side of the comparison should be avoided,
4        Detects comparisons that `comparison-of-constants` core checker cannot detect.
5        """
6        const_operands = []
7        LEFT_OPERAND = 0
8        RIGHT_OPERAND = 1
9
10        left_operand = node.left
11        const_operands.append(isinstance(left_operand, nodes.Const))
12
13        right_operand = node.ops[0][1]
14        const_operands.append(isinstance(right_operand, nodes.Const))
15
16        if all(const_operands):
17            # `comparison-of-constants` avoided
18            return
19
20        operand_value = None
21        if const_operands[LEFT_OPERAND] and self._is_magic_value(left_operand):
22            operand_value = left_operand.value
23        elif const_operands[RIGHT_OPERAND] and self._is_magic_value(right_operand):
24            operand_value = right_operand.value
25        if operand_value is not None:
26            self.add_message(
27                "magic-value-comparison",
28                node=node,
29                args=(operand_value),
30                confidence=HIGH,
31            )
            

Path 4: 1 calls (0.07)

Compare (1)

None (1)

1def _check_constants_comparison(self, node: nodes.Compare) -> None:
2        """
3        Magic values in any side of the comparison should be avoided,
4        Detects comparisons that `comparison-of-constants` core checker cannot detect.
5        """
6        const_operands = []
7        LEFT_OPERAND = 0
8        RIGHT_OPERAND = 1
9
10        left_operand = node.left
11        const_operands.append(isinstance(left_operand, nodes.Const))
12
13        right_operand = node.ops[0][1]
14        const_operands.append(isinstance(right_operand, nodes.Const))
15
16        if all(const_operands):
17            # `comparison-of-constants` avoided
18            return
19
20        operand_value = None
21        if const_operands[LEFT_OPERAND] and self._is_magic_value(left_operand):
22            operand_value = left_operand.value
23        elif const_operands[RIGHT_OPERAND] and self._is_magic_value(right_operand):
24            operand_value = right_operand.value
25        if operand_value is not None:
26            self.add_message(
27                "magic-value-comparison",
28                node=node,
29                args=(operand_value),
30                confidence=HIGH,
31            )