mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-09 21:28:04 +00:00
![]() ## Summary Part of #18972 This PR makes [for-loop-writes (FURB122)](https://docs.astral.sh/ruff/rules/for-loop-writes/#for-loop-writes-furb122)'s example error out-of-the-box. I also had to re-name the second case's variables to get both to raise at the same time, I suspect because of limitations in ruff's current semantic model. New names subject to bikeshedding, I just went with the least effort `_b` for binary suffix. [Old example](https://play.ruff.rs/19e8e47a-8058-4013-aef5-e9b5eab65962) ```py with Path("file").open("w") as f: for line in lines: f.write(line) with Path("file").open("wb") as f: for line in lines: f.write(line.encode()) ``` [New example](https://play.ruff.rs/e96b00e5-3c63-47c3-996d-dace420dd711) ```py from pathlib import Path with Path("file").open("w") as f: for line in lines: f.write(line) with Path("file").open("wb") as f_b: for line_b in lines_b: f_b.write(line_b.encode()) ``` The "Use instead" section was also modified similarly. ## Test Plan <!-- How was it tested? --> N/A, no functionality/tests affected |
||
---|---|---|
.. | ||
ruff | ||
ruff_annotate_snippets | ||
ruff_benchmark | ||
ruff_cache | ||
ruff_db | ||
ruff_dev | ||
ruff_diagnostics | ||
ruff_formatter | ||
ruff_graph | ||
ruff_index | ||
ruff_linter | ||
ruff_macros | ||
ruff_notebook | ||
ruff_options_metadata | ||
ruff_python_ast | ||
ruff_python_ast_integration_tests | ||
ruff_python_codegen | ||
ruff_python_formatter | ||
ruff_python_index | ||
ruff_python_literal | ||
ruff_python_parser | ||
ruff_python_semantic | ||
ruff_python_stdlib | ||
ruff_python_trivia | ||
ruff_python_trivia_integration_tests | ||
ruff_server | ||
ruff_source_file | ||
ruff_text_size | ||
ruff_wasm | ||
ruff_workspace | ||
ty | ||
ty_ide | ||
ty_project | ||
ty_python_semantic | ||
ty_server | ||
ty_static | ||
ty_test | ||
ty_vendored | ||
ty_wasm |