Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NeilGirdhar opened this issue Nov 22, 2024 · 0 comments · May be fixed by #14831
Open

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

NeilGirdhar opened this issue Nov 22, 2024 · 0 comments · May be fixed by #14831
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule type-inference Requires more advanced type inference.

Comments

@NeilGirdhar
Copy link

NeilGirdhar commented Nov 22, 2024

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.

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule needs-decision Awaiting a decision from a maintainer type-inference Requires more advanced type inference. and removed needs-decision Awaiting a decision from a maintainer labels Nov 22, 2024
@MichaReiser MichaReiser added the needs-decision Awaiting a decision from a maintainer label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule type-inference Requires more advanced type inference.
Projects
None yet
2 participants