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

Remove black formatter to use only ruff #1783

Merged
merged 1 commit into from
Oct 30, 2023
Merged

Remove black formatter to use only ruff #1783

merged 1 commit into from
Oct 30, 2023

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Oct 27, 2023

Following https://astral.sh/blog/the-ruff-formatter, I suggest we remove black formatter completely. It was already not very used anyway. Made a few changes so that current code is formatted the same with both black and ruff to reduce inconveniences for existing contributors.
N°1 argument IMO is speed. N°2 is that it's convenient to have everything handled by the same tool.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Oct 27, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Great, thank you! Would be great to align with transformers/accelerate/diffusers/others

cc @charliermarsh, you might be interested :)

@Wauplin
Copy link
Contributor Author

Wauplin commented Oct 30, 2023

Thanks @LysandreJik for the review :)

And immensely grateful @charliermarsh for the amazing work on Ruff ❤️

@Wauplin Wauplin merged commit 33f5f5f into main Oct 30, 2023
@Wauplin Wauplin deleted the use-ruff-formatter branch October 30, 2023 08:53
@charliermarsh
Copy link

Amazing, thanks @Wauplin and @LysandreJik! So cool to see :)

Comment on lines -184 to 185
# Format with black
code = black.format_file_contents(code, fast=False, mode=black.FileMode(line_length=119))

# Format with ruff
with tempfile.TemporaryDirectory() as tmpdir:
filepath = Path(tmpdir) / "__init__.py"

Choose a reason for hiding this comment

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

The call to ruff without arguments will not format but check.
See #27144 where we heavily rely on the formatting of the # Copied from

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!
Fixed this in #1824.

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.

5 participants