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

[MAINTENANCE] Replace black formatter with ruff format #9536

Merged
merged 30 commits into from Mar 5, 2024
Merged

Conversation

Kilo59
Copy link
Member

@Kilo59 Kilo59 commented Feb 26, 2024

Replacing the black formatter with ruff format

https://docs.astral.sh/ruff/formatter/

The initial goal of the Ruff formatter is not to innovate on code style, but rather, to innovate on performance, and provide a unified toolchain across Ruff's linter, formatter, and any and all future tools.

As such, the formatter is designed as a drop-in replacement for Black, but with an excessive focus on performance and direct integration with Ruff.

Deviations from Black (Explanation and Examples)

Note:

Some of the changes in this PR are because ruff format is copying a more recent version of black 24.2.0, whereas we had been stuck on 23.11.0

Update Ruff 0.2.2 -> 0.3.0

https://github.com/astral-sh/ruff/releases/tag/v0.3.0

TODO

If we decide to adopt this formatter I will...

  • Before merge
    • address the lining errors caused by formatting changes that move noqa comments.
  • After merge
    • add .gitblame-ignore-revs entry

See also

@Kilo59 Kilo59 changed the title Replace black formatter with ruff format [MAINTENANCE] Replace black formatter with ruff format Feb 26, 2024
Copy link

netlify bot commented Feb 26, 2024

Deploy Preview for niobium-lead-7998 canceled.

Name Link
🔨 Latest commit 68f9e9b
🔍 Latest deploy log https://app.netlify.com/sites/niobium-lead-7998/deploys/65e79a80da0d4b0008e44736

pyproject.toml Show resolved Hide resolved
@Kilo59 Kilo59 self-assigned this Feb 26, 2024
Copy link
Contributor

@billdirks billdirks left a comment

Choose a reason for hiding this comment

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

In general, I'm happy with this change. I think we need to do a few things before merging:

  • Add file ignores
  • Add #noqa back
  • Update PR autopopulated message to remove mention of black
  • I also added comments to the toml file for rules I'd like to be turned on if possible

pyproject.toml Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
Copy link
Member Author

@Kilo59 Kilo59 Mar 4, 2024

Choose a reason for hiding this comment

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

# fmt: off outside of the top-level/statement level is a known issue with the ruff formatter

Can fix this by de-denting the # fmt: off comment or by adding a trailing # fmt: skip, but these will disable formatting for more than just the parameter values.

Edit:
Addressed with # fmt: skip

@Kilo59 Kilo59 mentioned this pull request Mar 4, 2024
4 tasks
@Kilo59 Kilo59 marked this pull request as ready for review March 4, 2024 15:35
@Kilo59 Kilo59 requested review from cdkini and billdirks March 4, 2024 15:48
Copy link
Contributor

@billdirks billdirks left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

@Kilo59 Kilo59 enabled auto-merge March 5, 2024 21:34
@Kilo59 Kilo59 disabled auto-merge March 5, 2024 21:36
@Kilo59 Kilo59 enabled auto-merge March 5, 2024 21:50
@Kilo59 Kilo59 added this pull request to the merge queue Mar 5, 2024
Merged via the queue into develop with commit 697d591 Mar 5, 2024
67 checks passed
@Kilo59 Kilo59 deleted the m/_/ruff-fmt branch March 5, 2024 22:58
deborahniesz pushed a commit that referenced this pull request Mar 12, 2024
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

None yet

2 participants