diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs index f94fb7e0bff775..80be40cf4f9bb3 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs @@ -1,6 +1,6 @@ use rustpython_parser::ast::{self, Expr, Ranged}; -use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic}; +use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; use crate::checkers::ast::Checker; @@ -85,9 +85,14 @@ pub(crate) fn unnecessary_call_around_sorted( expr.range(), ); if checker.patch(diagnostic.kind.rule()) { - #[allow(deprecated)] - diagnostic.try_set_fix_from_edit(|| { - fixes::fix_unnecessary_call_around_sorted(checker.locator, checker.stylist, expr) + diagnostic.try_set_fix(|| { + let edit = + fixes::fix_unnecessary_call_around_sorted(checker.locator, checker.stylist, expr)?; + if outer == "reversed" { + Ok(Fix::suggested(edit)) + } else { + Ok(Fix::automatic(edit)) + } }); } checker.diagnostics.push(diagnostic); diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C413_C413.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C413_C413.py.snap index 84cf1eaf9ab869..73baaa38092739 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C413_C413.py.snap +++ b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C413_C413.py.snap @@ -12,7 +12,7 @@ C413.py:3:1: C413 [*] Unnecessary `list` call around `sorted()` | = help: Remove unnecessary `list` call -ℹ Suggested fix +ℹ Fix 1 1 | x = [2, 3, 1] 2 2 | list(x) 3 |-list(sorted(x))