Move to ruff-formatter & update settings #778
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This replaces both
isort
andblack
with ruff's new tooling.Ruff contained
isort
support for a while, however it was not entirely compatible with our custom isort rules before. Ruff has made some significant progress, which allows us to now completely replaceisort
with ruff's version of it. The advantage of doing this is obviously one less dependency, but additionally, ruff is also much fater than isort, and the import formatting can now happen duringruff check
(linter run) through auto-fixes.More recently (though it was a few months now), ruff has added support for an integrated code formatter, which is intended to replace black. In vast majority of it's formatting rules, it will be the same as black, so there are essentially no changes to the actual code after running
ruff format
. (other than some minor things, like to#fmt: off
comments, which ruff handles slightly differently, where ruff will only ignore full statements, not individual lines, so these comments had to be moved around a bit, or changed to# fmt: skip
on the appropriate statement).This new formatter is much faster than black was, and integrates nicely with our existing ruff configuration.
Lastly, this PR also updates some of ruff's settings/options, as a lot of what we were doing is now deprecated in newer versions of rust (such as setting
select
rules in[tools.ruff]
instead of[tools.ruff.lint]
. Or using the--show-source
CLI argument.