Are you guys particularly attached to flake8, or c...
# contribute
i
Are you guys particularly attached to flake8, or can we switch to ruff?
s
Nope not attached. Ideally it doesn’t cause us to reformat the entire code base 🙂 I forget, how does
ruff
interact with
black
I thought they’re kind of similar? or?
i
I think if ruff runs on a black-formatted codebase, it doesn't change anything. But if both tools are run on an unformatted codebase, results will be slightly different
Ruff rules can be added little by little to avoid a major reformat. It has a bunch of autofixes, so reformatting is quite easy.
s
sure — I think in the .pre-commit config yaml you can set the order so that it runs after black. Would
ruff
also replace
isort
?
i
To get isort functionality one must enable a particular family of checks (
I
).
s
https://docs.astral.sh/ruff/formatter/#black-compatibility seems like we can just drop black too then?
👍 1
yep I just saw that (the deviations part)
🙌 1
only way to find out is to run it 🙂
i
Yeah I experimented with that. The real question is setting up the right codes (to ignore/include)
s
Is there a way to populate that from the black, flake8, and isort settings we have?
i
In general - probably yes. Flake codes work exactly the same (with the exception of two that ruff doesn't recognize). Line length works the same. Ruff is highly configurable so I'm guessing any other settings can be specified too.
s
cool — so do you for see any issues to replace everything with Ruff then? Just thinking about when to call that PR done 🙂
i
We can do it in two stages if you prefer
BTW, why is the
docs
folder excluded from formatting?
s
We can do it in two stages if you prefer
I’m a momentum guy. So up to you.
BTW, why is the
docs
folder excluded from formatting?
because it contains code snippets that we’ve formatted differently to make them fit / appear nicer in the docs. E.g. the code comparison pages.
i
Just for the sake of order, let's split into two. Because introducing ruff might require reformatting some files, and I don't want it to appear in the same PR - since those are quite unrelated changes. I'm keeping the ruff configurations in
pyproject.toml
out of laziness and since these have no effect on the hooks. We won't be losing any momentum since the ruff PR will come right after
👍 1