Derived from the flake8-comprehensions linter.
Fix is always available.
What it does#
Checks for unnecessary
reversed calls around
Why is this bad?#
It is unnecessary to use
sorted, as the latter already
returns a list.
It is also unnecessary to use
sorted, as the latter
reverse argument that can be used in lieu of an additional
In both cases, it's clearer to avoid the redundant call.
This rule's fix is marked as unsafe, as
yield different results in the event of custom sort keys or equality
reversed will reverse the order of the
reverse=True will perform a stable
reverse sort, which will preserve the order of elements that compare as