-
-
Notifications
You must be signed in to change notification settings - Fork 426
Open
Labels
Description
Summary
Propose migrating from Black to Ruff as the default formatter for significantly improved performance.
Motivation
Performance Benchmarks
Tested with a 2000-definition schema (3 runs average):
| Formatter | Format Time | Improvement |
|---|---|---|
| Black + isort | 2.355s | (baseline) |
| Ruff format + isort | 0.487s | 79% faster |
| Ruff format only | 0.243s | 90% faster |
Total processing time improvement: 29-33%
For large schemas (like Kubernetes CRDs with 10,000+ definitions), formatting can be a major bottleneck. This change would significantly improve the user experience for large-scale code generation.
Adoption Statistics (December 2025)
| Package | Monthly Downloads | GitHub Stars |
|---|---|---|
| ruff | 111M | 44.7k |
| black | 90M | 41.2k |
Ruff has surpassed Black in downloads and is now used by major projects including:
- Pydantic (our primary output format)
- FastAPI, Pandas, PyTorch, Hugging Face, Apache Airflow, and 118,000+ other projects
Compatibility
Ruff formatter achieves >99.9% compatibility with Black (source).
Proposal
Phase 1: Documentation + Deprecation Warning
-
Update documentation to recommend Ruff as the preferred formatter
- Add migration guide
- Document performance benefits
-
Add DeprecationWarning when Black formatter is used
warnings.warn( "Black formatter is deprecated and will be removed in a future version. " "Consider using --formatters ruff-format for better performance.", DeprecationWarning, )
Phase 2: Change Default (Future Major Release)
- Change
DEFAULT_FORMATTERSfrom[black, isort]to[ruff-format] - Users can still use
--formatters black,isortfor the original behavior
Considerations
- Add
ruffas a required dependency (currently optional) - Determine timeline for Phase 2
Related
- Addresses performance concerns from
_get_unique_nametake really long with large swagger definition fileΒ #2286
Feedback welcome via comments or reactions.
ilovelinuxcoderabbitai