Exemplo n.º 1
0
 def _check_literal_compare(self, node: ast.Compare) -> None:
     last_was_literal = nodes.is_literal(get_assigned_expr(node.left))
     for comparator in map(get_assigned_expr, node.comparators):
         next_is_literal = nodes.is_literal(comparator)
         if last_was_literal and next_is_literal:
             self.add_violation(ConstantCompareViolation(node))
             break
         last_was_literal = next_is_literal
Exemplo n.º 2
0
 def _check_literal_compare(self, node: ast.Compare) -> None:
     last_was_literal = nodes.is_literal(node.left)
     for comparator in node.comparators:
         next_is_literal = nodes.is_literal(comparator)
         if last_was_literal and next_is_literal:
             self.add_violation(ConstantCompareViolation(node))
             break
         last_was_literal = next_is_literal