[perflint] Clarify that PERF402 applies to any iterable - #26242
Merged
Conversation
…ral-sh#21593) The previous wording described PERF402 as catching copies of an existing list, but the rule fires whenever a for-loop appends each item of any iterable to a list. Reword "What it does" and "Why is this bad?" to match the actual behavior. The violation message and rule logic are unchanged. Closes astral-sh#21593.
ntBre
reviewed
Jun 22, 2026
ntBre
left a comment
Contributor
There was a problem hiding this comment.
Thanks! Just a couple of small suggestions.
perflint] Clarify that PERF402 applies to any iterable
|
Contributor
Author
|
Good calls. I dropped the parens everywhere and re-added the |
Contributor
Author
|
@ntBre pinging here for update. Forgot to @ you at the previous comment! |
Contributor
|
Thanks, but you don't need to ping us. Any comment or commit puts this back in my review queue. I just haven't had a chance to take another look yet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First contribution here, hi! Picking up #21593 as a small intro PR.
PERF402's current "What it does" says it catches copies of an "existing list", but the rule also fires whenever a
forloop appends every item of any iterable to a list while the source isn't required to be a list (only the destination is). The issue reporter pointed this out and suggested wording closer to "for loops that can be replaced withlist()", which is what I went with here.Scope is intentionally tiny: just the
## What it doesand## Why is this bad?doc comments. Violation message, example, rule logic, and tests are unchanged so no snapshots move.Closes #21593.