Replace Black formatter with Ruff#1246
Conversation
📝 WalkthroughWalkthroughReplaces ChangesReplace black with ruff formatter
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Strift
left a comment
There was a problem hiding this comment.
Almost 4x increase in formatting time!
Thanks for this @DhavalGojiya ❤️
Description
Replace the
blackformatter with Ruff.Ruffis a fast Python linter and formatter written in Rust.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
Tests
1)
uv run ruff format --check .2) Black vs Ruff CI Speed Comparison
Black (15s)
Ruff (4s)
PR checklist
Please check if your PR fulfills the following requirements:
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)blackformatting jobruffjob that runsruff format --checkto verify formatting complianceContributing Guide (
CONTRIBUTING.md)isortuv run ruff format .Project Configuration (
pyproject.toml)blackfrom dev dependenciesruffto dev dependencies[tool.black]configuration with[tool.ruff]section (configured withline-length = 100)Code Formatting Updates
meilisearch/_httprequests.py: Reformatted JSON request-body serialization ternary expressions insend_requestandpost_streammethods to multi-line conditional expressionstests/client/test_client_exports.py: Reformattedtest_export_creationfunction signature from multi-line to single-linetests/client/test_multimodal.py: Simplified assertion expression insetup_indexfixture to use cleaner multi-line formattingAll 78 files in the repository were verified to meet Ruff formatting standards using
uv run ruff format --check.