Skip to content

implement ruff for auto-formatting and linting#137

Merged
gknapp1 merged 13 commits intomainfrom
ruff
Feb 4, 2026
Merged

implement ruff for auto-formatting and linting#137
gknapp1 merged 13 commits intomainfrom
ruff

Conversation

@gknapp1
Copy link
Collaborator

@gknapp1 gknapp1 commented Feb 2, 2026

This replaces black autoformatting with ruff autoformatting and linting.

The autoformatter is the same as black, but it is more straightforward to use a single tool.

The ruff linter's static analysis is very fast, but limited in scope of what it checks compared to pylint. I have added the ruff linting as a pre-commit check and CI step to maintain the basic quality of the code. This PR also fixes all of the ruff linter's warnings so that it passes this new check.

The pylint CI step also still runs with the same behavior. It requires code to not significantly decrease the overall quality of the code beyond the current threshold, but it does not fail if pylint warnings are found.

@gknapp1 gknapp1 marked this pull request as draft February 2, 2026 13:06
Copy link
Collaborator

@streeve streeve left a comment

Choose a reason for hiding this comment

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

I'm seeing that ruff is better at finding unused variables, prefers explicit public module listing, and has a very slightly different formatting default

@gknapp1
Copy link
Collaborator Author

gknapp1 commented Feb 3, 2026

I'm seeing that ruff is better at finding unused variables, prefers explicit public module listing, and has a very slightly different formatting default

For what it's worth, pylint also found those issues, but it doesn't seem to weigh them highly when it comes up with its numerical score of code quality, so they tend to make it through the quality threshold check. For example, fixing all of the Ruff linting issues only moved the code quality from a pylint 8.23/10 to 8.49/10.

Because Ruff is fast, I find it nicer to work with as an IDE extension to catch simple mistakes.

@gknapp1 gknapp1 marked this pull request as ready for review February 3, 2026 16:43
Copy link
Collaborator

@streeve streeve left a comment

Choose a reason for hiding this comment

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

It's not obvious to me that the ruff checks will actually cause CI failure when the checks fail (one would hope, but I've made the mistake of assuming before)

@gknapp1 gknapp1 merged commit 33e7a28 into main Feb 4, 2026
6 checks passed
@gknapp1 gknapp1 deleted the ruff branch February 4, 2026 14:52
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