[flake8-comprehensions] bugfix for C413 autofix (#2804)

This commit is contained in:
Simon Brugman 2023-02-12 16:56:07 +01:00 committed by GitHub
parent f8ac6d7bf0
commit 2dccb7611a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 156 additions and 5 deletions

View file

@ -0,0 +1,29 @@
# unnecessary-call-around-sorted (C413)
Derived from the **flake8-comprehensions** linter.
Autofix is always available.
## What it does
Checks for unnecessary `list` or `reversed` calls around `sorted`
calls.
## Why is this bad?
It is unnecessary to use `list` around `sorted`, as the latter already
returns a list.
It is also unnecessary to use `reversed` around `sorted`, as the latter
has a `reverse` argument that can be used in lieu of an additional
`reversed` call.
In both cases, it's clearer to avoid the redundant call.
## Examples
```python
reversed(sorted(iterable))
```
Use instead:
```python
sorted(iterable, reverse=True)
```