Skip to content

Migrate to Ruff as the default formatter for improved performanceΒ #2775

@koxudaxi

Description

@koxudaxi

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

  1. Update documentation to recommend Ruff as the preferred formatter

    • Add migration guide
    • Document performance benefits
  2. 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)

  1. Change DEFAULT_FORMATTERS from [black, isort] to [ruff-format]
  2. Users can still use --formatters black,isort for the original behavior

Considerations

  • Add ruff as a required dependency (currently optional)
  • Determine timeline for Phase 2

Related


Feedback welcome via comments or reactions.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions