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

Move to ruff-formatter & update settings #778

Merged
merged 1 commit into from
Mar 31, 2024
Merged

Conversation

ItsDrike
Copy link
Member

This replaces both isort and black 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 replace isort 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 during ruff 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.

@ItsDrike
Copy link
Member Author

ItsDrike commented Mar 27, 2024

Note: the failed CI is not related to this PR, it's failing to build readthedocs due to a import error for dns. This likely has to do with some package getting auto-updated and breaking compatibility or something like that.

@ItsDrike ItsDrike added type: enhancement Improvement to an existing feature area: dependencies Related to package dependencies status: needs review Author is waiting for someone to review and approve area: CI Related to continuous intergration and deployment labels Mar 27, 2024
Copy link
Member

@PerchunPak PerchunPak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that it tries to maintain indentation for comment, honestly lacked this feature in black.

pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@ItsDrike ItsDrike force-pushed the ruff-formatter branch 2 times, most recently from eaa58ea to 9f9f9a2 Compare March 27, 2024 15:32
@PerchunPak PerchunPak merged commit 1086db5 into master Mar 31, 2024
9 checks passed
@PerchunPak PerchunPak deleted the ruff-formatter branch March 31, 2024 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: CI Related to continuous intergration and deployment area: dependencies Related to package dependencies status: needs review Author is waiting for someone to review and approve type: enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants