Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repeat-until-convergence #10954

Closed
KDruzhkin opened this issue Apr 15, 2024 · 1 comment
Closed

repeat-until-convergence #10954

KDruzhkin opened this issue Apr 15, 2024 · 1 comment

Comments

@KDruzhkin
Copy link

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.

[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__ import annotations

from typing import TypeAlias

import numpy.typing as t

ID: TypeAlias = int


def foo(x: t.NDArray) -> int:
    return len(x)

I obediently click Ctrl_+. and select a quick fix.

Now, this code is flagged with I001 ("Import block is unsorted"):

from __future__ import annotations

from typing import TypeAlias, TYPE_CHECKING


if TYPE_CHECKING:
    import numpy.typing as t

ID: TypeAlias = int


def foo(x: t.NDArray) -> int:
    return len(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:

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'.

@KDruzhkin
Copy link
Author

KDruzhkin commented Apr 16, 2024

Sorry, does not belong to ruff itself, but to ruff-vscode.

astral-sh/ruff-vscode#451.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant