Skip to content

Setup Ruff + pre-commit for linting and formatting

SandhyaRani Bandaram requested to merge roughcheck into feature-final

What does this MR do and why?

This Merge Request adds Ruff linting and pre-commit hooks to improve code quality, maintain consistent formatting, and enhance developer experience.

Changes Made

  • Added Ruff linting and formatting using pre-commit hooks
  • Updated .pre-commit-config.yaml to use Ruff v0.11.5
  • Enabled automatic fixes and exit-on-fix behavior
  • Configured pyproject.toml to detect unused imports by removing F401 from ignore rules
  • Auto-formatted 54 files using Ruff
  • Fixed 1 unused import detected by Ruff
  • Added code quality setup instructions to README.md

Why this change is needed

This improves the developer workflow by:

  • Automatically formatting code before commits
  • Preventing unused imports and lint errors
  • Maintaining consistent code style across the project
  • Improving overall code quality and maintainability
  • Enhancing Developer Experience (DX)

References

Ruff Documentation: https://docs.astral.sh/ruff/\ Pre-commit Documentation: https://pre-commit.com/


How to set up and validate locally

  1. Checkout this branch:

    git checkout roughcheck

  2. Install dependencies:

    pip install pre-commit ruff

  3. Install pre-commit hooks:

    pre-commit install

  4. Run pre-commit on all files:

    pre-commit run --all-files

  5. Make a test commit to verify Ruff runs automatically:

    git add . git commit -m "Test pre-commit Ruff"

Ruff should automatically format files and fix lint issues before the commit is completed.


    • Ruff linting configured
    • Code builds and runs locally
    • Pre-commit hooks installed and working
    • Documentation updated in README
    • No breaking changes introduced
    • Code formatted using Ruff
    • Unused imports removed

Merge request reports

Loading