Improvements to RUF015 (#7848)

## Summary

Resolves https://github.com/astral-sh/ruff/issues/7618. 

The list of builtin iterator is not exhaustive.

## Test Plan

`cargo test`

``` python
a = [1, 2]

examples = [
    enumerate(a),
    filter(lambda x: x, a),
    map(int, a),
    reversed(a),
    zip(a),
    iter(a),
]

for example in examples:
    print(next(example))
```
This commit is contained in:
Simon Høxbro Hansen 2023-10-08 16:49:45 +02:00 committed by GitHub
parent 62f1ee08e7
commit 2ba5677700
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 247 additions and 25 deletions

View file

@ -337,3 +337,11 @@ pub fn is_builtin(name: &str) -> bool {
| "zip"
)
}
/// Returns `true` if the given name is that of a Python builtin iterator.
pub fn is_iterator(name: &str) -> bool {
matches!(
name,
"enumerate" | "filter" | "map" | "reversed" | "zip" | "iter"
)
}