Skip to content

Rule suggestion: Convert list.extend([x]) to list.append(x) #14518

Open
@NeilGirdhar

Description

This may depend on RedKnot, but with type information, this could hit a lot of code. If we know retval is a list, consider converting:

retval.extend([x]) 

to

retval.append(x)

And similarly, merge

retval.extend([x, y])
retval.append(v)
retval.extend([z, w])

etc.

It may not seem like merging will catch a lot of cases, but having the Ruff action available makes it available in my editor, which is a great convenience.

Metadata

Assignees

No one assigned

    Labels

    needs-decisionAwaiting a decision from a maintainerruleImplementing or modifying a lint ruletype-inferenceRequires more advanced type inference.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions