Skip to content

Consider adopting astral-sh/ruff for formatting and linting #437

Description

@burgholzer

What is your issue?

The current code base uses black and pylint for formatting and linting.
Pylint is well known for being very slow and better alternatives exist in the meantime.
Ruff is a blazing fast Python formatter and linter developed by the folks at Astral that build high performance tooling for Python. See https://docs.astral.sh/ruff/ for their excellent documentation.
For the most part, these are a simple drop in replacement for the existing tools.
There is a pre-commit hook that you can run as

  # Python linting using ruff
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.14.3
    hooks:
      - id: ruff-check
        args: ["--fix", "--show-fixes"]
      - id: ruff-format

For an (exhaustive) example configuration of ruff, you could use https://github.com/munich-quantum-toolkit/core/blob/98c31eb50cc6e84b676b0545237aee4ce21a6339/pyproject.toml#L204-L249 as inspiration.
Note that this enables quite a couple of linting rules, so do not be surprised if the first run screams at you with quite a few warnings. Ruff has great autofixes for many of its rules.
I can really only recommend it.

This is part of openjournals/joss-reviews#9125

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions