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

[perflint] Catch a wider range of mutations in PERF101 #9955

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

charliermarsh
Copy link
Member

Summary

This PR ensures that if a list x is modified within a for loop, we avoid flagging list(x) as unnecessary. Previously, we only detected calls to exactly .append, and they couldn't be nested within other statements.

Closes #9925.

@charliermarsh charliermarsh added the bug Something isn't working label Feb 12, 2024
@charliermarsh charliermarsh marked this pull request as ready for review February 12, 2024 17:00
@charliermarsh charliermarsh merged commit 0304623 into main Feb 12, 2024
17 checks passed
@charliermarsh charliermarsh deleted the charlie/append branch February 12, 2024 17:17
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

nkxxll pushed a commit to nkxxll/ruff that referenced this pull request Mar 10, 2024
…#9955)

## Summary

This PR ensures that if a list `x` is modified within a `for` loop, we
avoid flagging `list(x)` as unnecessary. Previously, we only detected
calls to exactly `.append`, and they couldn't be nested within other
statements.

Closes astral-sh#9925.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PERF101 false positive
1 participant