mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 05:20:49 -05:00
## Summary
Part of #15584
This adds a `Fix safety` section to [for-loop-writes
(FURB122)](https://docs.astral.sh/ruff/rules/for-loop-writes/#for-loop-writes-furb122).
The fix/lint was introduced in #10630
No reasoning is given on the unsafety in the PR/code.
The unsafety is determined here:
ea812d0813/crates/ruff_linter/src/rules/refurb/rules/for_loop_writes.rs (L200-L204)
Unsafe fix demonstration:
[playground](https://play.ruff.rs/06592f33-10b9-4a77-b31e-0d3a98f402f4)
```py
with open("issue.txt", "w") as f:
for i in range(10):
# will be deleted
f.write(str(i))
```
---------
Co-authored-by: Dylan <dylwil3@gmail.com>