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

Adds ruff as a drop in replacement for black #91

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rachfop
Copy link
Contributor

@rachfop rachfop commented Nov 3, 2023

What was changed

Replaces Black with Ruff formatter.

Recently, ruff added the ability to format:
https://docs.astral.sh/ruff/formatter/

Known deviations:

https://docs.astral.sh/ruff/formatter/black/#newlines-are-inserted-after-all-class-docstrings

Removed isort:

Added a skip isort in the .giitignore file:
https://pycqa.github.io/isort/docs/configuration/action_comments.html

Ruff respects isort's action comments (# isort: skip_file, # isort: on, # isort: off, # isort: skip, and # isort: split), which enable selectively enabling and disabling import sorting for blocks of code and other inline configuration.

Ruff uses isort's profile = black by default:
https://docs.astral.sh/ruff/faq/#how-does-ruffs-import-sorting-compare-to-isort>

Ruff's import sorting is intended to be near-equivalent to isort's when using isort's profile = "black".

Why?

Faster 🐎

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

@cretz
Copy link
Member

cretz commented Nov 3, 2023

Nice! I'd like to see about doing this to our SDK repo too. Can it replace isort too?

@rachfop
Copy link
Contributor Author

rachfop commented Nov 5, 2023

Good call. Removed isort and updated the description of this pr with how it works.

@cretz
Copy link
Member

cretz commented Nov 6, 2023

@rachfop - Not understanding exactly. So does this provide all the import sorting benefit of isort? If we're removing isort, why have a comment in the gitignore relating to the tool we don't use/support anymore?

@rachfop
Copy link
Contributor Author

rachfop commented Nov 6, 2023

Ruff supports isort's action comments, so we can remove isort from the pyproject.tom, but use isort's skip_file and ruff wil respect that.
I only included that because it was a part of the original pyproject.toml sorting logic.

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@cretz
Copy link
Member

cretz commented Nov 9, 2023

Looks like a lock conflict. I think you can merge main and just run poetry lock --no-update to fix

@rachfop
Copy link
Contributor Author

rachfop commented Nov 9, 2023

Resolved merge!

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.

2 participants