[perflint] Catch a wider range of mutations in PERF101 (#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 https://github.com/astral-sh/ruff/issues/9925.
This commit is contained in:
Charlie Marsh 2024-02-12 12:17:55 -05:00 committed by GitHub
parent e2785f3fb6
commit 0304623878
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 132 additions and 44 deletions

View file

@ -935,7 +935,7 @@ where
}
}
/// A [`StatementVisitor`] that collects all `return` statements in a function or method.
/// A [`Visitor`] that collects all `return` statements in a function or method.
#[derive(Default)]
pub struct ReturnStatementVisitor<'a> {
pub returns: Vec<&'a ast::StmtReturn>,