Replies: 1 comment
|
Use the formatter for the mechanical whitespace cleanup, then the linter for policy checks: ruff format .
ruff check --fix .
ruff format --check .
ruff check .
Two caveats: Ruff intentionally does not rewrite whitespace inside string literals, and it will preserve blank lines when removing them could change meaning or comments. If the “tabs” are literal characters embedded in generated data or multiline strings, a Python formatter should not touch them; use a targeted migration script and exclude generated files instead. It is worth committing the formatting change separately from behavioral edits. That keeps blame and review manageable, especially when cleaning an existing codebase in one pass. |
Uh oh!
There was an error while loading. Please reload this page.
I am working on a codebase where there are lots of extra tabs, for example:
I'd like to automatically make those just one tab and set up checks going forward that it's not the case. How can I do this with ruff?
Similarly, I'd like to also make it so if something can be on one line while obeying the line lengths that it is put on one line. How can I enforce that?
All reactions