You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some fixes, when applied, create conditions for other fixes.
I would like to have a configuration option to run ruff check --fix until convergence, i.e. until no new changes can be made.
[tool.ruff.lint]
repeat_until_convergence = true
I work in Visual Studio Code with Ruff extension. If the extension behaves differently from command-line ruff check --fix, it should be configurable as well.
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"):
from __future__ importannotationsfromtypingimportTypeAliasimportnumpy.typingastID: TypeAlias=intdeffoo(x: t.NDArray) ->int:
returnlen(x)
I obediently click Ctrl_+. and select a quick fix.
Now, this code is flagged with I001 ("Import block is unsorted"):
from __future__ importannotationsfromtypingimportTypeAlias, TYPE_CHECKINGifTYPE_CHECKING:
importnumpy.typingastID: TypeAlias=intdeffoo(x: t.NDArray) ->int:
returnlen(x)
Sometimes the chain is longer than two steps, but I cannot reproduce it now.
An analogy
Phonology and historical linguistics study phonological rules, i.e. regularities of the form "change A to B in context C". At the verty heart of this study is the notion of ordering: one rule can trigger or block another rule:
TL;DR
Some fixes, when applied, create conditions for other fixes.
I would like to have a configuration option to run
ruff check --fix
until convergence, i.e. until no new changes can be made.I work in Visual Studio Code with Ruff extension. If the extension behaves differently from command-line
ruff check --fix
, it should be configurable as well.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"):
Sometimes the chain is longer than two steps, but I cannot reproduce it now.
An analogy
Phonology and historical linguistics study phonological rules, i.e. regularities of the form "change A to B in context C". At the verty heart of this study is the notion of ordering: one rule can trigger or block another rule:
Further questions
Is the order of rules fixed or not? (Is it part of the public API?) If you change this order internally, can it be a breaking change?
Is it difficult to create a graph of interactions? If rule A can trigger (or block) rule B, I would like to see it in the documentation for the rules.
Keywords
I have searched open issues with: 'recursive' (found #6254), 'iterative' (found #8272), 'fixed point' (found #10058), 'fixpoint', and 'convergence'.
The text was updated successfully, but these errors were encountered: