Skip to content

Switch python tooling to ruff - #1018

Open
mohitt31 wants to merge 1 commit into
AIDASoft:masterfrom
mohitt31:harmonize-python-tooling
Open

Switch python tooling to ruff#1018
mohitt31 wants to merge 1 commit into
AIDASoft:masterfrom
mohitt31:harmonize-python-tooling

Conversation

@mohitt31

@mohitt31 mohitt31 commented Sep 3, 2026

Copy link
Copy Markdown

The python tool configuration was spread over three files that disagreed with each other. .flake8 set the line length to 99, setup.cfg carried a second [flake8] section setting it to 120 plus [pycodestyle] and [pep8] sections for tools that aren't run at all, and pyproject.toml configured 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: 402 in 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-toplevel suppressions 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 .flake8 already 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: disable comments in about ten files that are inert now. I left those for a separate PR rather than growing this one.

Ran ruff check and ruff format --check over all 55 files pre-commit looks at, including the extensionless scripts in tools/. Both clean.

BEGINRELEASENOTES

  • Replace black, flake8 and pylint with ruff and ruff-format
  • Move the python tool configuration into a single .ruff.toml and remove .flake8, setup.cfg and pyproject.toml
    ENDRELEASENOTES

Fixes #703

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Harmonize python tool configuration

1 participant