Open KDruzhkin opened 2 months ago
For reference, we do fix until convergence if you run Fix All
.
For reference, we do fix until convergence if you run
Fix All
.
Yes, I was in a hurry when I wrote https://github.com/astral-sh/ruff/issues/10954, but now I see.
Perhaps, I should rename this issue to cleanup-after-fix?
Doesn't Fix All
code action do exactly that? It'll try to apply the fixes until there are none. Or, am I misunderstanding on what you're trying to achieve?
Doesn't
Fix All
code action do exactly that? It'll try to apply the fixes until there are none. Or, am I misunderstanding on what you're trying to achieve?
Not exactly. Suppose I have lots of ugly code below which I do not want to touch just yet. But I am ready to fix the imports. In this situation I cannot run Fix All
.
I see. Thanks for sharing that. I think https://github.com/astral-sh/ruff/issues/4361 could potentially solve this at least when working from the command-line. I'm not sure what it would look like in the editor.
TL;DR
Some fixes, when applied, create conditions for other fixes.
On one hand, I understand that VSCode extension fixes one thing at a time (and this is by design). On the other hand, it is not fun to fix violations created by the tool.
I would like to have a configuration option for ruff to clean up after itself:
An example
Recently I went through a large code base, adding
from __future__ import annotations
where it missed. This simple change started a cascade of other changes.This code is flagged with TCH002 ("Move
numpy.typing
into a type-checking block"):I obediently
click Ctrl_+.
and select a quick fix.Now, this code is flagged with I001 ("Import block is unsorted"), because
TypeAlias, TYPE_CHECKING
are in the wrong order, and there is an extra newline beforeif TYPE_CHECKING
:Clicking again, I get the final version:
Sometimes the chain is longer than two steps, but I cannot reproduce it now.