Skip to content

🚀 Refactoring Proposal: Adopt Ruff for Integrated Linting and Formatting #337

@Borda

Description

@Borda

Motivation (Current Limitations)

Our current setup relies on black (formatting) and isort (import sorting). This leaves two key gaps:

  1. Missing Linting: No automated checks for common bugs, anti-patterns, or adherence to best practices (e.g., Flake8/Pylint rules).

  2. Toolchain Overhead: Managing separate dependencies and execution steps for black and isort adds unnecessary complexity to our CI/CD pipeline and local development loop.

Proposal (Solution)

Integrate Ruff as the single, high-performance tool for linting, import sorting, and formatting. Ruff is an extremely fast, Rust-based utility designed to consolidate the Python code quality pipeline.

Justification: Progressive Improvement

Ruff offers a compelling improvement over the current setup, delivering speed and functionality beyond simple formatting:

Feature Benefit Progressive Change from Current
Extreme Speed Drastically reduces CI/CD runtimes and local pre-commit check times. Improves developer feedback cycles significantly.
Tool Consolidation Replaces isort entirely and is a drop-in formatter for black. Simplifies dependencies and reduces toolchain maintenance.
Code Quality Assurance Instantly enforces 600+ linting rules (Flake8, Pylint subsets) to catch bugs and anti-patterns. Introduces vital quality checks that black and isort do not provide.

Recommended Action Plan

  1. Dependency Update: Add ruff and remove isort.

  2. Configuration: Define [tool.ruff] in pyproject.toml, setting line-length = 88 and enabling a core set of linting rules (e.g., ["E", "F", "W", "I", "UP"]).

  3. Initial Fix: Run ruff check --fix . across the codebase.

  4. CI/CD: Update CI scripts to use ruff check and ruff format --check (or keep black initially during a transition phase).

Next Steps

If approved, I will submit a PR implementing this transition (Phase 1: Ruff for linting/sorting, replacing isort).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions