From 805d179dc07aa574b82d9786926d0e4ae516f71c Mon Sep 17 00:00:00 2001 From: Dan Parizher <105245560+danparizher@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:23:57 -0400 Subject: [PATCH] [`flake8-comprehensions`] Clarify fix safety documentation (`C413`) (#20640) ## Summary Fixes #20632 --- .../rules/unnecessary_call_around_sorted.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs index 08395c5ea3..ad3f1c5b11 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs @@ -32,12 +32,15 @@ use crate::rules::flake8_comprehensions::fixes; /// ``` /// /// ## Fix safety -/// This rule's fix is marked as unsafe, as `reversed()` and `reverse=True` will -/// yield different results in the event of custom sort keys or equality -/// functions. Specifically, `reversed()` will reverse the order of the -/// collection, while `sorted()` with `reverse=True` will perform a stable +/// This rule's fix is marked as unsafe for `reversed()` cases, as `reversed()` +/// and `reverse=True` will yield different results in the event of custom sort +/// keys or equality functions. Specifically, `reversed()` will reverse the order +/// of the collection, while `sorted()` with `reverse=True` will perform a stable /// reverse sort, which will preserve the order of elements that compare as /// equal. +/// +/// The fix is marked as safe for `list()` cases, as removing `list()` around +/// `sorted()` does not change the behavior. #[derive(ViolationMetadata)] pub(crate) struct UnnecessaryCallAroundSorted { func: UnnecessaryFunction,