Method: pylint.extensions.comparison_placement.MisplacedComparisonConstantChecker.visit_compare
Calls: 12, Exceptions: 0, Paths: 3Back
Path 1: 7 calls (0.58)
Compare (7)
1@utils.only_required_for_messages("misplaced-comparison-constant")
2 def visit_compare(self, node: nodes.Compare) -> None:
3 # NOTE: this checker only works with binary comparisons like 'x == 42'
4 # but not 'x == y == 42'
5 if len(node.ops) != 1:
6 return
7
8 left = node.left
9 operator, right = node.ops[0]
10 if operator in COMPARISON_OPERATORS and isinstance(left, nodes.Const):
11 self._check_misplaced_constant(node, left, right, operator)
Path 2: 3 calls (0.25)
Compare (3)
1@utils.only_required_for_messages("misplaced-comparison-constant")
2 def visit_compare(self, node: nodes.Compare) -> None:
3 # NOTE: this checker only works with binary comparisons like 'x == 42'
4 # but not 'x == y == 42'
5 if len(node.ops) != 1:
6 return
7
8 left = node.left
9 operator, right = node.ops[0]
10 if operator in COMPARISON_OPERATORS and isinstance(left, nodes.Const):
11 self._check_misplaced_constant(node, left, right, operator)
Path 3: 2 calls (0.17)
Compare (2)
None (2)
1@utils.only_required_for_messages("misplaced-comparison-constant")
2 def visit_compare(self, node: nodes.Compare) -> None:
3 # NOTE: this checker only works with binary comparisons like 'x == 42'
4 # but not 'x == y == 42'
5 if len(node.ops) != 1:
6 return
7
8 left = node.left
9 operator, right = node.ops[0]
10 if operator in COMPARISON_OPERATORS and isinstance(left, nodes.Const):
11 self._check_misplaced_constant(node, left, right, operator)