[Preview] Toolchain upgrade (black, flake8 -> ruff)

Hey folks, if has been a while since we introduced black for formatting python source code.
Keeping a consistent look and feel across the project, I think has been a success.

But there is a new kid in town: ruff [0]
What sticks out to me, is not so much that it is “10-100x faster than existing linters (like Flake8) and formatters (like Black)”, but that it consolidates the tasks of black, isort and flake8 into one tool, that it allows to auto-fix more issues than black alone and that it can even serve as a language-server (lsp) for better editor support (neovim in my case).
The formatting decisions taken by ruff are intentionally almost the same as by black.

I expect us to eventually switch completely to using ruff. But for now I will prepare a showcase for this transition in the Pulp CLI repository. So stay tuned.

[0] Ruff

3 Likes

First shots look promising:

No objections to this. Fewer tools and configurations to keep track of sounds good to me.

A look at the formatting results in the given example looks perfectly fine, with two caveats:

  1. I personally liked the ability to throw in a newline in between pulp-specific and non-pulp dependency groups, it looks like maybe it may not like that?

  2. I would like to see the impact on one of the plugins, where the different warnings ignored by the previous flake8 config might reappear. I seem to recall most of those on the ignore list were worthy of being there.

1 Like

We didn’t do isort yet on pulp plugins, but there is even a setting i think for exactly what you are talking about there:
https://docs.astral.sh/ruff/settings/#lint_isort_sections