Skip to content

Commit 2589a29

Browse files
authored
[flake8-simplify] Make example error out-of-the-box (SIM113) (#19109)
<!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> Part of #18972 This PR makes [enumerate-for-loop (SIM113)](https://docs.astral.sh/ruff/rules/enumerate-for-loop/#enumerate-for-loop-sim113)'s example error out-of-the-box [Old example](https://play.ruff.rs/a6ef6fec-eb6b-477c-a962-616f0b8e1491) ```py fruits = ["apple", "banana", "cherry"] for fruit in fruits: print(f"{i + 1}. {fruit}") i += 1 ``` [New example](https://play.ruff.rs/1811d608-1aa0-45d8-96dc-18105e74b8cc) ```py fruits = ["apple", "banana", "cherry"] i = 0 for fruit in fruits: print(f"{i + 1}. {fruit}") i += 1 ``` ## Test Plan <!-- How was it tested? --> N/A, no functionality/tests affected
1 parent 26bb8f7 commit 2589a29

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

crates/ruff_linter/src/rules/flake8_simplify/rules/enumerate_for_loop.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use crate::checkers::ast::Checker;
2020
/// ## Example
2121
/// ```python
2222
/// fruits = ["apple", "banana", "cherry"]
23+
/// i = 0
2324
/// for fruit in fruits:
2425
/// print(f"{i + 1}. {fruit}")
2526
/// i += 1

0 commit comments

Comments
 (0)