Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@
assert (not foo) in bar
assert {"x": not foo} in bar
assert [42, not foo] in bar

# https://github.com/astral-sh/ruff/issues/17582
if True == True: # No duplicated diagnostic
pass
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,16 @@ pub(crate) fn literal_comparisons(checker: &Checker, compare: &ast::ExprCompare)
if let Expr::BooleanLiteral(ast::ExprBooleanLiteral { value, .. }) = next {
match op {
EqCmpOp::Eq => {
if let Expr::BooleanLiteral(ast::ExprBooleanLiteral {
value: comparator_value,
..
}) = comparator
{
if value == comparator_value {
continue;
}
}

let cond = if compare.ops.len() == 1 {
Some(SourceCodeSnippet::from_str(
checker.locator().slice(comparator),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,20 @@ E712.py:31:4: E712 [*] Avoid equality comparisons to `True`; use `if yield i:` f
32 32 | print("even")
33 33 |
34 34 | #: Okay

E712.py:58:4: E712 [*] Avoid equality comparisons to `True`; use `if True:` for truth checks
|
57 | # https://github.com/astral-sh/ruff/issues/17582
58 | if True == True: # No duplicated diagnostic
| ^^^^^^^^^^^^ E712
59 | pass
|
= help: Replace with `True`

ℹ Unsafe fix
55 55 | assert [42, not foo] in bar
56 56 |
57 57 | # https://github.com/astral-sh/ruff/issues/17582
58 |-if True == True: # No duplicated diagnostic
58 |+if True: # No duplicated diagnostic
59 59 | pass
Loading