From 29f66533185a9e796b9058e11ab2e0a9962b6b3c Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Wed, 8 Jan 2025 15:56:19 +0100 Subject: [PATCH] [`ruff`] Stabilize `useless-if-else` (`RUF034`) (#15351) --- crates/ruff_linter/src/codes.rs | 2 +- crates/ruff_linter/src/rules/ruff/rules/useless_if_else.rs | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/crates/ruff_linter/src/codes.rs b/crates/ruff_linter/src/codes.rs index f1ca749fe5723..41dc2a31786d2 100644 --- a/crates/ruff_linter/src/codes.rs +++ b/crates/ruff_linter/src/codes.rs @@ -982,7 +982,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Ruff, "031") => (RuleGroup::Preview, rules::ruff::rules::IncorrectlyParenthesizedTupleInSubscript), (Ruff, "032") => (RuleGroup::Stable, rules::ruff::rules::DecimalFromFloatLiteral), (Ruff, "033") => (RuleGroup::Stable, rules::ruff::rules::PostInitDefault), - (Ruff, "034") => (RuleGroup::Preview, rules::ruff::rules::UselessIfElse), + (Ruff, "034") => (RuleGroup::Stable, rules::ruff::rules::UselessIfElse), (Ruff, "035") => (RuleGroup::Preview, rules::ruff::rules::UnsafeMarkupUse), (Ruff, "036") => (RuleGroup::Preview, rules::ruff::rules::NoneNotAtEndOfUnion), (Ruff, "037") => (RuleGroup::Preview, rules::ruff::rules::UnnecessaryEmptyIterableWithinDequeCall), diff --git a/crates/ruff_linter/src/rules/ruff/rules/useless_if_else.rs b/crates/ruff_linter/src/rules/ruff/rules/useless_if_else.rs index 1299c94459915..57ebbd18bca2e 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/useless_if_else.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/useless_if_else.rs @@ -9,20 +9,15 @@ use ruff_python_ast::comparable::ComparableExpr; /// /// ## Why is this bad? /// Useless `if`-`else` conditions add unnecessary complexity to the code without -/// providing any logical benefit. -/// -/// Assigning the value directly is clearer and more explicit, and -/// should be preferred. +/// providing any logical benefit. Assigning the value directly is clearer. /// /// ## Example /// ```python -/// # Bad /// foo = x if y else x /// ``` /// /// Use instead: /// ```python -/// # Good /// foo = x /// ``` #[derive(ViolationMetadata)]