Skip to content

C413 documentation implies the fix is unsafer than it is #20632

@dscorbett

Description

@dscorbett

Summary

The documentation for unnecessary-call-around-sorted (C413) says:

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 reverse sort, which will preserve the order of elements that compare as equal.

That makes it sound like the fix is always marked as unsafe. In fact, it is marked as unsafe for reversed and safe for list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions