Skip to content

[Toolchain]: Migrate to Ruff and remove legacy linting/formatting tools #13

@Harmeet10000

Description

@Harmeet10000

Prerequisites

  • I have searched the existing issues
  • I'm running the latest version

Node.js Version

3.12

Environment

Development

Current Behavior

The project currently uses multiple legacy tools for linting and formatting:

  • Black (v24.10.0) - Code formatting
  • isort (v5.13.2) - Import sorting
  • Pylint (v3.3.2) - Linting
  • Flake8 (if installed) - Linting

This creates:

  • Dependency bloat with 4+ separate tools
  • Slower CI/CD pipelines
  • Configuration fragmentation across multiple sections
  • Potential conflicts between tools (e.g., ISC001 warning)

Expected Behavior

Consolidate to Ruff (v0.7.1+) as the single tool for:

  • Code formatting (replaces Black)
  • Import sorting (replaces isort)
  • Linting (replaces Pylint/Flake8)

Benefits:

  • 10-100x faster than existing tools
  • Single configuration section
  • Unified pre-commit hooks
  • Reduced dependency count

Steps To Reproduce

  1. Check pyproject.toml [project.optional-dependencies] section
  2. See Black, isort, Pylint listed
  3. Check [tool.black] and [tool.isort] configurations
  4. Check .pre-commit-config.yaml for multiple formatter/linter hooks

Error Logs

This is causing frequent IDE crashes.

Additional Context

Migration Checklist

1. Update Dependencies

# Remove legacy packages
uv pip uninstall black isort pylint flake8

# Reinstall with updated dev dependencies
uv pip install -e ".[dev]"

2. Configuration Changes

  • Remove black, isort, pylint from pyproject.toml dev dependencies
  • Remove [tool.black] configuration section
  • Remove [tool.isort] configuration section
  • Add [tool.ruff], [tool.ruff.lint], [tool.ruff.format] sections
  • Add ISC001 to ignore list to prevent formatter conflicts

3. Pre-commit Hooks

  • Remove Black hook from .pre-commit-config.yaml
  • Remove isort hook from .pre-commit-config.yaml
  • Update to use astral-sh/ruff-pre-commit with both ruff and ruff-format hooks

4. CI/CD Updates

  • Update GitHub Actions workflows to use ruff check instead of black --check and isort --check-only
  • Update CI to use ruff format --check for format validation
  • Remove Pylint/Flake8 steps if present

5. Documentation Updates

  • Update README.md with new Ruff commands
  • Update CONTRIBUTING.md (if exists) with Ruff workflow
  • Update q-rules.md to reference Ruff instead of Black/isort

6. Validation

# Format all code
ruff format .

# Run linter with auto-fix
ruff check . --fix

# Verify pre-commit hooks
pre-commit install
pre-commit run --all-files

# Run tests to ensure no breakage
pytest

Configuration Reference

Ruff Configuration (pyproject.toml)

[tool.ruff]
line-length = 88
target-version = "py312"

[tool.ruff.lint]
select = ["E", "F", "I", "N", "W", "UP", "B", "A", "C4", "DTZ", "T10", "EM", "ISC", "ICN", "PIE", "PT", "Q", "RSE", "RET", "SIM", "TID", "ARG", "PTH", "PD", "PL", "TRY", "RUF"]
ignore = ["E501", "ISC001", "TRY003", "PLR0913", "PLR2004"]

[tool.ruff.lint.isort]
known-first-party = ["src"]

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions