mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-31 07:37:38 +00:00
![]() ## Summary Implement [`no-ignored-enumerate-items`](https://github.com/dosisod/refurb/blob/master/refurb/checks/builtin/no_ignored_enumerate.py) as `unnecessary-enumerate` (`FURB148`). The auto-fix considers if a `start` argument is passed to the `enumerate()` function. If only the index is used, then the suggested fix is to pass the `start` value to the `range()` function. So, ```python for i, _ in enumerate(xs, 1): ... ``` becomes ```python for i in range(1, len(xs)): ... ``` If the index is ignored and only the value is ignored, and if a start value greater than zero is passed to `enumerate()`, the rule doesn't produce a suggestion. I couldn't find a unanimously accepted best way to iterate over a collection whilst skipping the first n elements. The rule still triggers, however. Related to #1348. ## Test Plan `cargo test` --------- Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com> |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |