Skip to content

[flake8-comprehensions] C413 autofix bug #4879

@zariiii9003

Description

@zariiii9003

The autofix for C413 can lead to bugs if the key parameter is used. Here is a little code example to show, that the results before and after the autofix are different.

original = [(1, 0), (2, 0), (3, 1), (4, 1)]
print(list(reversed(sorted(original, key=lambda x: x[1]))))
print(sorted(original, key=lambda x: x[1], reverse=True))

Here is the output:

[(4, 1), (3, 1), (2, 0), (1, 0)]
[(3, 1), (4, 1), (1, 0), (2, 0)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionAsking for support or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions