Method: pylint.checkers.base.comparison_checker.ComparisonChecker.visit_compare
Calls: 1141, Exceptions: 0, Paths: 4Back
Path 1: 516 calls (0.45)
Compare (516)
1@utils.only_required_for_messages(
2 "singleton-comparison",
3 "unidiomatic-typecheck",
4 "literal-comparison",
5 "comparison-with-itself",
6 "comparison-of-constants",
7 "comparison-with-callable",
8 "nan-comparison",
9 )
10 def visit_compare(self, node: nodes.Compare) -> None:
11 self._check_callable_comparison(node)
12 self._check_logical_tautology(node)
13 self._check_unidiomatic_typecheck(node)
14 self._check_constants_comparison(node)
15 # NOTE: this checker only works with binary comparisons like 'x == 42'
16 # but not 'x == y == 42'
17 if len(node.ops) != 1:
18 return
19
20 left = node.left
21 operator, right = node.ops[0]
22
23 if operator in {"==", "!="}:
24 self._check_singleton_comparison(
25 left, right, node, checking_for_absence=operator == "!="
26 )
27
28 if operator in {"==", "!=", "is", "is not"}:
29 self._check_nan_comparison(
30 left, right, node, checking_for_absence=operator in {"!=", "is not"}
31 )
32 if operator in {"is", "is not"}:
33 self._check_literal_comparison(right, node)
Path 2: 482 calls (0.42)
Compare (482)
1@utils.only_required_for_messages(
2 "singleton-comparison",
3 "unidiomatic-typecheck",
4 "literal-comparison",
5 "comparison-with-itself",
6 "comparison-of-constants",
7 "comparison-with-callable",
8 "nan-comparison",
9 )
10 def visit_compare(self, node: nodes.Compare) -> None:
11 self._check_callable_comparison(node)
12 self._check_logical_tautology(node)
13 self._check_unidiomatic_typecheck(node)
14 self._check_constants_comparison(node)
15 # NOTE: this checker only works with binary comparisons like 'x == 42'
16 # but not 'x == y == 42'
17 if len(node.ops) != 1:
18 return
19
20 left = node.left
21 operator, right = node.ops[0]
22
23 if operator in {"==", "!="}:
24 self._check_singleton_comparison(
25 left, right, node, checking_for_absence=operator == "!="
26 )
27
28 if operator in {"==", "!=", "is", "is not"}:
29 self._check_nan_comparison(
30 left, right, node, checking_for_absence=operator in {"!=", "is not"}
31 )
32 if operator in {"is", "is not"}:
33 self._check_literal_comparison(right, node)
Path 3: 106 calls (0.09)
Compare (106)
1@utils.only_required_for_messages(
2 "singleton-comparison",
3 "unidiomatic-typecheck",
4 "literal-comparison",
5 "comparison-with-itself",
6 "comparison-of-constants",
7 "comparison-with-callable",
8 "nan-comparison",
9 )
10 def visit_compare(self, node: nodes.Compare) -> None:
11 self._check_callable_comparison(node)
12 self._check_logical_tautology(node)
13 self._check_unidiomatic_typecheck(node)
14 self._check_constants_comparison(node)
15 # NOTE: this checker only works with binary comparisons like 'x == 42'
16 # but not 'x == y == 42'
17 if len(node.ops) != 1:
18 return
19
20 left = node.left
21 operator, right = node.ops[0]
22
23 if operator in {"==", "!="}:
24 self._check_singleton_comparison(
25 left, right, node, checking_for_absence=operator == "!="
26 )
27
28 if operator in {"==", "!=", "is", "is not"}:
29 self._check_nan_comparison(
30 left, right, node, checking_for_absence=operator in {"!=", "is not"}
31 )
32 if operator in {"is", "is not"}:
33 self._check_literal_comparison(right, node)
Path 4: 37 calls (0.03)
Compare (37)
None (37)
1@utils.only_required_for_messages(
2 "singleton-comparison",
3 "unidiomatic-typecheck",
4 "literal-comparison",
5 "comparison-with-itself",
6 "comparison-of-constants",
7 "comparison-with-callable",
8 "nan-comparison",
9 )
10 def visit_compare(self, node: nodes.Compare) -> None:
11 self._check_callable_comparison(node)
12 self._check_logical_tautology(node)
13 self._check_unidiomatic_typecheck(node)
14 self._check_constants_comparison(node)
15 # NOTE: this checker only works with binary comparisons like 'x == 42'
16 # but not 'x == y == 42'
17 if len(node.ops) != 1:
18 return
19
20 left = node.left
21 operator, right = node.ops[0]
22
23 if operator in {"==", "!="}:
24 self._check_singleton_comparison(
25 left, right, node, checking_for_absence=operator == "!="
26 )
27
28 if operator in {"==", "!=", "is", "is not"}:
29 self._check_nan_comparison(
30 left, right, node, checking_for_absence=operator in {"!=", "is not"}
31 )
32 if operator in {"is", "is not"}:
33 self._check_literal_comparison(right, node)