Skip to content

Replace Pylint with Ruff#194

Open
Thom747 wants to merge 16 commits intoQuTech-Delft:mainfrom
Thom747:replace-pylint-with-ruff
Open

Replace Pylint with Ruff#194
Thom747 wants to merge 16 commits intoQuTech-Delft:mainfrom
Thom747:replace-pylint-with-ruff

Conversation

@Thom747
Copy link
Copy Markdown
Collaborator

@Thom747 Thom747 commented Apr 7, 2026

This PR replaces the slow Pylint formatter with Ruff.

As Ruff does not output a score, but just fails on any errors, this PR also made the requirement on the amount of linting errors more stringent: from a Pylint score of 9.0 to 0 errors.

@Thom747 Thom747 requested a review from heevasti April 7, 2026 13:10
@Thom747 Thom747 self-assigned this Apr 7, 2026
Copy link
Copy Markdown
Collaborator

@heevasti heevasti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly little changes in the end, I would have thought it would have been at least double the number. So that's good, nicely tuned! My main comments are that we should have also a badge for ruff, now that pylint badge gets dropped, and that the Ruff does not need to evaluate the unit-tests modules so no "# noqa: ..." lines should be needed there. The some code neatness changes already present can be kept, but no need to make the Ruff pass the unit-tests in the future.

def test_parse_symbols_no_dots(self):
"""Test the path is returned into a subfolder if no dots present."""
global TEST_PROGRAM
global TEST_PROGRAM # noqa: PLW0603
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the formatter has also re-formatted parts of the testing module. It is fine for some small code improvements but these "noqa" should not be here as unit-tests should be left outside of the code formatting checks. For unit-tests it is important that they work, not how they look.

Copy link
Copy Markdown
Collaborator Author

@Thom747 Thom747 Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that formatting is not the issue at hand, but linting is. Note that none of these changes are due to the ruff formatter, as that was not invoked (or fully configured) for this PR.

Unittests should still be correct and ideally not bug-prone and that is what the linter is for.
The usage of globals in the unittests, for instance, is a code smell and a potential source of errors.
I think deviating from that at times can be warranted, but that is what the noqa comments are for.
I would thus like to propose we do not special-case the tests for the linter.

@@ -1,4 +1,3 @@
[![pylint](https://github.com/QuTech-Delft/QMI/blob/main/.github/badges/pylint.svg)](https://github.com/QuTech-Delft/QMI/blob/main/.github/badges/pylint.svg)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This badge should be replaced with a Ruff 'pass' or 'fail' -kind badge, or 'pass' or 'errors: n' -kind.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, didn't know that existed. I'll see how I can create something like that. However, is it useful to have such a badge if, much like mypy, any error will cause the pipeline to fail and thus prevent a merge into main?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a badge that shows the amount of ruff errors. What do you think?

git fetch origin "${{ github.head_ref }}" || true
git checkout "${{ github.head_ref }}"
pip install anybadge
anybadge -o -l pylint -v $(tail -n 2 pylint-3.11.log | grep -o '[0-9]\{1,2\}\.[0-9]\{2\}' | head -n 1) -f $BADGES_DIR/pylint.svg 2=red 4=orange 8=yellow 10=green
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a ruff badge that gets created in place of the pylint badge. A simple 'pass' | 'fail' badge should suffice for Ruff, as it does not really produce a "score". Alternatively, a 'pass' or 'errors: n' kind of badge.

@Thom747 Thom747 force-pushed the replace-pylint-with-ruff branch from f72fbcd to a628477 Compare April 8, 2026 14:22
@Thom747 Thom747 requested a review from heevasti April 8, 2026 14:50
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.

2 participants