mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-27 15:03:51 +00:00
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:
parent
62f1ee08e7
commit
2ba5677700
4 changed files with 247 additions and 25 deletions
|
@ -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"
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue