Skip to content

Commit c97d157

Browse files
committed
Deprecate UP027 (#12843)
Co-authored-by: Alex Waygood <[email protected]> Closes #12754
1 parent e4de0e9 commit c97d157

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

crates/ruff_linter/src/codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
510510
(Pyupgrade, "024") => (RuleGroup::Stable, rules::pyupgrade::rules::OSErrorAlias),
511511
(Pyupgrade, "025") => (RuleGroup::Stable, rules::pyupgrade::rules::UnicodeKindPrefix),
512512
(Pyupgrade, "026") => (RuleGroup::Stable, rules::pyupgrade::rules::DeprecatedMockImport),
513-
(Pyupgrade, "027") => (RuleGroup::Stable, rules::pyupgrade::rules::UnpackedListComprehension),
513+
(Pyupgrade, "027") => (RuleGroup::Deprecated, rules::pyupgrade::rules::UnpackedListComprehension),
514514
(Pyupgrade, "028") => (RuleGroup::Stable, rules::pyupgrade::rules::YieldInForLoop),
515515
(Pyupgrade, "029") => (RuleGroup::Stable, rules::pyupgrade::rules::UnnecessaryBuiltinImport),
516516
(Pyupgrade, "030") => (RuleGroup::Stable, rules::pyupgrade::rules::FormatLiterals),

crates/ruff_linter/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ use ruff_text_size::Ranged;
77

88
use crate::checkers::ast::Checker;
99

10+
/// ## Deprecation
11+
/// There's no [evidence](https://github.com/astral-sh/ruff/issues/12754) that generators are
12+
/// meaningfully faster than list comprehensions when combined with unpacking.
13+
///
1014
/// ## What it does
1115
/// Checks for list comprehensions that are immediately unpacked.
1216
///
1317
/// ## Why is this bad?
1418
/// There is no reason to use a list comprehension if the result is immediately
15-
/// unpacked. Instead, use a generator expression, which is more efficient as
16-
/// it avoids allocating an intermediary list.
19+
/// unpacked. Instead, use a generator expression, which avoids allocating
20+
/// an intermediary list.
1721
///
1822
/// ## Example
1923
/// ```python

0 commit comments

Comments
 (0)