From bbcddf7e7982da73f79c2db4be6b337f43c224f8 Mon Sep 17 00:00:00 2001 From: Brent Westbrook <36778786+ntBre@users.noreply.github.com> Date: Tue, 11 Mar 2025 11:30:43 -0400 Subject: [PATCH] [`pylint`] Stabilize `len-test` (`PLC1802`) (#16626) Summary -- Stabilizes PLC1802. The tests were already in the right place, and I just tidied the docs a little bit. Test Plan -- 1 issue closed 4 days after the rule was added, no other issues --- crates/ruff_linter/src/codes.rs | 2 +- crates/ruff_linter/src/rules/pylint/rules/len_test.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/ruff_linter/src/codes.rs b/crates/ruff_linter/src/codes.rs index 6a5fede515..b3156f0f0d 100644 --- a/crates/ruff_linter/src/codes.rs +++ b/crates/ruff_linter/src/codes.rs @@ -192,7 +192,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Pylint, "C0208") => (RuleGroup::Stable, rules::pylint::rules::IterationOverSet), (Pylint, "C0414") => (RuleGroup::Stable, rules::pylint::rules::UselessImportAlias), (Pylint, "C0415") => (RuleGroup::Preview, rules::pylint::rules::ImportOutsideTopLevel), - (Pylint, "C1802") => (RuleGroup::Preview, rules::pylint::rules::LenTest), + (Pylint, "C1802") => (RuleGroup::Stable, rules::pylint::rules::LenTest), (Pylint, "C1901") => (RuleGroup::Preview, rules::pylint::rules::CompareToEmptyString), (Pylint, "C2401") => (RuleGroup::Stable, rules::pylint::rules::NonAsciiName), (Pylint, "C2403") => (RuleGroup::Stable, rules::pylint::rules::NonAsciiImportName), diff --git a/crates/ruff_linter/src/rules/pylint/rules/len_test.rs b/crates/ruff_linter/src/rules/pylint/rules/len_test.rs index 7ff9e48043..28b531eef2 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/len_test.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/len_test.rs @@ -9,12 +9,11 @@ use ruff_python_semantic::{BindingId, SemanticModel}; use ruff_text_size::Ranged; /// ## What it does -/// Checks for usage of call of 'len' on sequences -/// in boolean test context. +/// Checks for `len` calls on sequences in a boolean test context. /// /// ## Why is this bad? /// Empty sequences are considered false in a boolean context. -/// You can either remove the call to 'len' +/// You can either remove the call to `len` /// or compare the length against a scalar. /// /// ## Example