Switch python tooling to ruff - #1018
Open
mohitt31 wants to merge 1 commit into
Open
Conversation
Replace black, flake8 and pylint with ruff and ruff-format, matching the setup EDM4hep already uses. The configuration was spread over .flake8, setup.cfg and pyproject.toml with two flake8 sections disagreeing on the line length, and setup.cfg also carried pycodestyle and pep8 sections for tools that were not run. All of that is now one .ruff.toml. Fixes AIDASoft#703
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The python tool configuration was spread over three files that disagreed with each other.
.flake8set the line length to 99,setup.cfgcarried a second[flake8]section setting it to 120 plus[pycodestyle]and[pep8]sections for tools that aren't run at all, andpyproject.tomlconfigured black at 99. Since the pre-commit hook passes--config=.flake8, the whole setup.cfg block was dead config. Nothing outside those files referenced them and there's no setup.py, so they're removed and the configuration is one.ruff.toml, copied from the one EDM4hep already uses.A few things turned up on the way.
# noqa: 402in arrow_io.py and sio_io.py is missing the E, so flake8 was reading it as a blanket noqa and it only worked by accident. The# pylint: disable=import-outside-toplevelsuppressions aren't readable by ruff, so they became# noqa: PLC0415. PLW2901 fires on two loop variables that pylint's redefined-loop-name doesn't flag, and since both are deliberate they got a noqa instead of a rewrite. The long lines in test_MemberParser.py are carried over as a per-file ignore, the same exemption.flake8already had.Six files reformat, because podio pins black 23.11.0 and ruff format follows the newer black style. Two things worth flagging: dropping pylint loses the import-error check, since ruff doesn't resolve imports, and there are stale
# pylint: disablecomments in about ten files that are inert now. I left those for a separate PR rather than growing this one.Ran
ruff checkandruff format --checkover all 55 files pre-commit looks at, including the extensionless scripts in tools/. Both clean.BEGINRELEASENOTES
.ruff.tomland remove.flake8,setup.cfgandpyproject.tomlENDRELEASENOTES
Fixes #703