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

Replace isort and black with ruff #274

Merged
merged 1 commit into from
Apr 29, 2024
Merged

Replace isort and black with ruff #274

merged 1 commit into from
Apr 29, 2024

Conversation

ItsDrike
Copy link
Member

@ItsDrike ItsDrike commented Apr 29, 2024

Recently (a while ago to be fair, but this project wasn't really updated for a long time), ruff has introduced their own formatter, which aims to replace black. It is almost 1:1 compatible with black, as can be seen by the small amount of changes made to the existing code.

Additionally, this also replaces isort with the built-in isort support in ruff. This was a feature for quite a while now, but there were some incompatibilities with isort, as not all isort settings were previously supported. That has since changed, and ruff now supports isort in the same configuration that we were using before.This therefore allows us to get rid of isort too.

This is a good thing, as it shouldn't introduce any real differences to the code style, while reducing the amount of necessary tools that contributors need to be working with, and even improving speed, as ruff is faster than isort or black (although realistically, pre-commit still won't be super fast, as pyright is the significant slow-down there).

Furthermore, this PR also updates ruff lint settings in pyproject.toml, adding some extra rules, and more importantly, renaming now deprecated section names for configuring ruff lint (ruff.* was changed to ruff.lint.*).

Task List:

  • Update the version of ruff that's being used to latest, and fix any new violations as a result of this update
  • Drop isort in favor of ruff's isort lint module
  • Drop black in favor of ruff formatter
  • Update pre-commit to use ruff instead of black & isort
  • Update GitHub workflows to use ruff instead of black & isort
  • Update contributing documents that mention black & isort in favor of ruff (this also adds an entry on slotscheck tool, which wasn't previously documented at all for some reason)

@ItsDrike ItsDrike added t: enhancement Improvement to an existing feature p: 2 - normal Normal priority a: CI Related to continuous integration and deployment a: dependencies Related to package dependencies and management a: internal Related to internal API of the project labels Apr 29, 2024
@ItsDrike ItsDrike mentioned this pull request Apr 29, 2024
@ItsDrike ItsDrike force-pushed the update-ruff branch 4 times, most recently from 365831b to 16b61ad Compare April 29, 2024 22:43
- This updates ruff itself, as we were using a very old version
- This updates the pyproject.toml configuration to use the renamed
  settings options (`ruff.lint` prefix, instead of just `ruff`).
- This drops black in favor of ruff auto-formatter.
- This drops isort in favor of ruff implementation of isort.
@ItsDrike ItsDrike marked this pull request as ready for review April 29, 2024 22:46
@ItsDrike ItsDrike merged commit 952097b into main Apr 29, 2024
10 of 11 checks passed
@ItsDrike ItsDrike deleted the update-ruff branch April 29, 2024 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: CI Related to continuous integration and deployment a: dependencies Related to package dependencies and management a: internal Related to internal API of the project p: 2 - normal Normal priority t: enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant