mdopt icon indicating copy to clipboard operation
mdopt copied to clipboard

Consider adopting `astral-sh/ruff` for formatting and linting

Open burgholzer opened this issue 2 months ago • 2 comments

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 https://github.com/openjournals/joss-reviews/issues/9125

burgholzer avatar Nov 07 '25 16:11 burgholzer

Thanks for the suggestion Lukas, however I am putting this issue on hold at the moment because pylint still does its job really well and scanning the whole codebase takes seconds on my laptop.

meandmytram avatar Nov 07 '25 21:11 meandmytram

Just saying, but switching to ruff would bring that down to milliseconds. You wouldn't even feel that it runs. From personal experience, this can really be a game changer when it comes to development experience.

burgholzer avatar Nov 07 '25 21:11 burgholzer