Skip to content

Commit 29f6653

Browse files
committed
[ruff] Stabilize useless-if-else (RUF034) (#15351)
1 parent d645525 commit 29f6653

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

crates/ruff_linter/src/codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
982982
(Ruff, "031") => (RuleGroup::Preview, rules::ruff::rules::IncorrectlyParenthesizedTupleInSubscript),
983983
(Ruff, "032") => (RuleGroup::Stable, rules::ruff::rules::DecimalFromFloatLiteral),
984984
(Ruff, "033") => (RuleGroup::Stable, rules::ruff::rules::PostInitDefault),
985-
(Ruff, "034") => (RuleGroup::Preview, rules::ruff::rules::UselessIfElse),
985+
(Ruff, "034") => (RuleGroup::Stable, rules::ruff::rules::UselessIfElse),
986986
(Ruff, "035") => (RuleGroup::Preview, rules::ruff::rules::UnsafeMarkupUse),
987987
(Ruff, "036") => (RuleGroup::Preview, rules::ruff::rules::NoneNotAtEndOfUnion),
988988
(Ruff, "037") => (RuleGroup::Preview, rules::ruff::rules::UnnecessaryEmptyIterableWithinDequeCall),

crates/ruff_linter/src/rules/ruff/rules/useless_if_else.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,15 @@ use ruff_python_ast::comparable::ComparableExpr;
99
///
1010
/// ## Why is this bad?
1111
/// Useless `if`-`else` conditions add unnecessary complexity to the code without
12-
/// providing any logical benefit.
13-
///
14-
/// Assigning the value directly is clearer and more explicit, and
15-
/// should be preferred.
12+
/// providing any logical benefit. Assigning the value directly is clearer.
1613
///
1714
/// ## Example
1815
/// ```python
19-
/// # Bad
2016
/// foo = x if y else x
2117
/// ```
2218
///
2319
/// Use instead:
2420
/// ```python
25-
/// # Good
2621
/// foo = x
2722
/// ```
2823
#[derive(ViolationMetadata)]

0 commit comments

Comments
 (0)