ruff
8a6db4f2 - Show fixes by default (#19919)

Commit
14 days ago
Show fixes by default (#19919) ## Summary This PR fixes #7352 by exposing the `show_fix_diff` option used in our snapshot tests in the CLI. As the issue suggests, we plan to make this the default output format in the future, so this is added to the `full` output format in preview for now. This turned out to be pretty straightforward. I just used our existing `Applicability` settings to determine whether or not to print the diff. The snapshot differences are because we now set `Applicability::DisplayOnly` for our snapshot tests. This `Applicability` is also used to determine whether or not the fix icon (`[*]`) is rendered, so this is now shown for display-only fixes in our snapshots. This was already the case previously, but we were only setting `Applicability::Unsafe` in these tests and ignoring the `Applicability` when rendering fix diffs. CLI users can't enable display-only fixes, so this is only a test change for now, but this should work smoothly if we decide to expose a `--display-only-fixes` flag or similar in the future. I also deleted the `PrinterFlags::SHOW_FIX_DIFF` flag. This was completely unused before, and it seemed less confusing just to delete it than to enable it in the right place and check it along with the `OutputFormat` and `preview`. ## Test Plan I only added one CLI test for now. I'm kind of assuming that we have decent coverage of the cases where this shouldn't be firing, especially the `output_format` CLI test, which shows that this definitely doesn't affect non-preview `full` output. I'm happy to add more tests with different combinations of options, if we're worried about any in particular. I did try `--diff` and `--preview` and a few other combinations manually. And here's a screenshot using our trusty UP049 example from the design discussion confirming that all the colors and other formatting still look as expected: <img width="786" height="629" alt="image" src="https://github.com/user-attachments/assets/94e408bc-af7b-4573-b546-a5ceac2620f2" /> And one with an unsafe fix to see the footer: <img width="782" height="367" alt="image" src="https://github.com/user-attachments/assets/bbb29e47-310b-4293-b2c2-cc7aee3baff4" /> ## Related issues and PR - https://github.com/astral-sh/ruff/issues/7352 - https://github.com/astral-sh/ruff/pull/12595 - https://github.com/astral-sh/ruff/issues/12598 - https://github.com/astral-sh/ruff/issues/12599 - https://github.com/astral-sh/ruff/issues/12600 I think we could probably close all of these issues now. I think we've either resolved or avoided most of them, and if we encounter them again with the new output format, it would probably make sense to open new ones anyway.
Author
Parents
Loading