Skip to content

Replace Black formatter with Ruff#1246

Merged
Strift merged 1 commit into
meilisearch:mainfrom
DhavalGojiya:feat/ruff-formatter
Jun 18, 2026
Merged

Replace Black formatter with Ruff#1246
Strift merged 1 commit into
meilisearch:mainfrom
DhavalGojiya:feat/ruff-formatter

Conversation

@DhavalGojiya

@DhavalGojiya DhavalGojiya commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Description

Replace the black formatter with Ruff.
Ruff is a fast Python linter and formatter written in Rust.

It is typically 10-100x faster than traditional Python tooling such as Flake8 and Black.

It provides linting and formatting in a single dependency, does not depend on Python itself, and includes good defaults, like automatically excluding unnecessary files and directories.

Summary

  • Updated the CI pipeline and contributing guide to use Ruff instead of Black.

Tests

1) uv run ruff format --check .

image

2) Black vs Ruff CI Speed Comparison

Black (15s)

image



Ruff (4s)

image

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary

This PR replaces the Black code formatter with Ruff, a fast Python linter and formatter written in Rust, which is documented as 10-100x faster than traditional Python tooling.

Changes

CI Pipeline (.github/workflows/tests.yml)

  • Removed the black formatting job
  • Added a new ruff job that runs ruff format --check to verify formatting compliance

Contributing Guide (CONTRIBUTING.md)

  • Updated formatting instructions to use Ruff instead of Black
  • Kept import sorting via isort
  • Updated example development commands to use uv run ruff format .

Project Configuration (pyproject.toml)

  • Removed black from dev dependencies
  • Added ruff to dev dependencies
  • Replaced [tool.black] configuration with [tool.ruff] section (configured with line-length = 100)

Code Formatting Updates

  • meilisearch/_httprequests.py: Reformatted JSON request-body serialization ternary expressions in send_request and post_stream methods to multi-line conditional expressions
  • tests/client/test_client_exports.py: Reformatted test_export_creation function signature from multi-line to single-line
  • tests/client/test_multimodal.py: Simplified assertion expression in setup_index fixture to use cleaner multi-line formatting

All 78 files in the repository were verified to meet Ruff formatting standards using uv run ruff format --check.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Replaces black with ruff as the code formatter across the project. pyproject.toml swaps the dependency and configuration, the CI workflow replaces the black job with a ruff job, CONTRIBUTING.md updates the formatting instructions, and affected source/test files are reformatted to comply with ruff's output.

Changes

Replace black with ruff formatter

Layer / File(s) Summary
Formatter tooling: config, CI, and docs
pyproject.toml, .github/workflows/tests.yml, CONTRIBUTING.md
pyproject.toml removes the black dependency and [tool.black] section, adds ruff with line-length = 100. The CI workflow replaces the black check job with a ruff job using ruff-action. CONTRIBUTING.md updates the formatting instructions and example commands to use uv run ruff format ..
Source and test reformatting
meilisearch/_httprequests.py, tests/client/test_client_exports.py, tests/client/test_multimodal.py
_httprequests.py splits two ternary body-construction expressions across multiple lines. test_client_exports.py collapses a multi-line def signature to a single line. test_multimodal.py rewrites the document-count assertion to a direct comparison with an explicit message string.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐇 Farewell to black, a formatter fine,
Now ruff hops in to redraw each line!
With line-length set at one-hundred wide,
The workflows rejoice, the CI runs with pride.
A formatter switch — small carrots, big cheer! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main objective of the PR: replacing Black formatter with Ruff across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread pyproject.toml

@sanders41 sanders41 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Strift I don't have access to update the required checks. We should remove black and add ruff to the required list.

@Strift Strift added the maintenance Anything related to maintenance (CI, tests, refactoring...) label Jun 18, 2026

@Strift Strift left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Almost 4x increase in formatting time!

Thanks for this @DhavalGojiya ❤️

@Strift Strift merged commit f51bb17 into meilisearch:main Jun 18, 2026
11 checks passed
@DhavalGojiya DhavalGojiya deleted the feat/ruff-formatter branch June 18, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Anything related to maintenance (CI, tests, refactoring...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants