mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-23 00:31:55 +00:00
[flake8-comprehensions
] Clarify fix safety documentation (C413
) (#20640)
## Summary Fixes #20632
This commit is contained in:
parent
f73ead11cb
commit
805d179dc0
1 changed files with 7 additions and 4 deletions
|
@ -32,12 +32,15 @@ use crate::rules::flake8_comprehensions::fixes;
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## Fix safety
|
/// ## Fix safety
|
||||||
/// This rule's fix is marked as unsafe, as `reversed()` and `reverse=True` will
|
/// This rule's fix is marked as unsafe for `reversed()` cases, as `reversed()`
|
||||||
/// yield different results in the event of custom sort keys or equality
|
/// and `reverse=True` will yield different results in the event of custom sort
|
||||||
/// functions. Specifically, `reversed()` will reverse the order of the
|
/// keys or equality functions. Specifically, `reversed()` will reverse the order
|
||||||
/// collection, while `sorted()` with `reverse=True` will perform a stable
|
/// of the collection, while `sorted()` with `reverse=True` will perform a stable
|
||||||
/// reverse sort, which will preserve the order of elements that compare as
|
/// reverse sort, which will preserve the order of elements that compare as
|
||||||
/// equal.
|
/// equal.
|
||||||
|
///
|
||||||
|
/// The fix is marked as safe for `list()` cases, as removing `list()` around
|
||||||
|
/// `sorted()` does not change the behavior.
|
||||||
#[derive(ViolationMetadata)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct UnnecessaryCallAroundSorted {
|
pub(crate) struct UnnecessaryCallAroundSorted {
|
||||||
func: UnnecessaryFunction,
|
func: UnnecessaryFunction,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue