Skip to content

Enforce code formatting with ruff format #45

Description

@janhoy

Summary

Now that #6 replaces pylint with ruff, the next step is to enforce consistent code formatting using `ruff format` — ruff's built-in formatter (compatible with Black's style).

Motivation

  • The entire codebase can be formatted in one pass with `ruff format .`
  • CI already runs `make lint`; adding `ruff format --check .` there enforces formatting on every PR
  • A single tool (ruff) now covers linting and formatting — no separate Black/isort dependency needed
  • Consistent formatting reduces noise in diffs and eliminates style debates in reviews

Proposed changes

  1. Format the codebase — run `ruff format .` once to reformat all ~250 Python files
  2. Enable the format check in `Makefile` — uncomment the `ruff format --check .` line in the `lint` target (the comment-placeholder was left there intentionally)
  3. Document for developers in `CONTRIBUTING.md` or `DEVELOPER_GUIDE.md`:
    • Run `ruff format .` before committing (or configure your editor to do it on save)
    • `make lint` will fail in CI if files are not formatted
    • Optional: recommend a pre-commit hook or IDE integration (VS Code `ruff` extension, etc.)

Notes

  • The formatting-only diff will be large (~190 files) but purely mechanical — no logic changes
  • It is best submitted as a standalone PR so reviewers can ignore it or review with whitespace-diff disabled (`?w=1` in GitHub)
  • The `[tool.ruff.format]` section can be added to `pyproject.toml` at that point (quote style, indent style)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions