Skip to content

Conversation

@kieran-ryan
Copy link
Contributor

@kieran-ryan kieran-ryan commented Dec 22, 2025

Replace flake8 with ruff for linting Python code.

Context

  • Closes Add Flake8 problem matcher #511 - provides native support for GitHub annotations through --output-format=github
  • Fixes and enforces quote formatting - applied through the automated fix ruff check --select=Q --fix - which is a drop-in replacement for flake8-quotes
    • Configuration for flake8-quotes was applied within .flake8, though as the dependency is not specified within the repository or installed within the pipeline, the formatted was not enforced or applied.
  • Drops redundant # noqa comments

See ruff's default configuration for documentation on default rule disparity with flake8.

# Ruff's default configuration - https://docs.astral.sh/ruff/configuration/
[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F"]
  • Automated linting fixes.
  • pyproject.toml support
  • Monorepo support
    • Respects configuration from root and within each package - run poe linter or ruff check from any location
    • IDE support during development - rather than relying on disparities between local task runs, CI, etc.
  • Orders of magnitude faster
  • Hundreds of rules, without requiring external plugins and dependencies
    • Can subsequently be extended for formatting and other linting criteria - though scoped to parity with this pull request
  • and more

Dropped legacy Jenkins linting configuration.

Checklist

- GitHub inline linting annotations.
- Resolve pre-existing quotation issues.
- Replace flake8 with ruff and monorepo configuration.
@kieran-ryan kieran-ryan force-pushed the debt/ruff-linting branch 2 times, most recently from 46afce6 to 8038393 Compare December 29, 2025 02:04
@delatrie
Copy link
Contributor

Hi, @kieran-ryan ! Thank you for this PR. I was thinking about switching to ruff myself. I had some positive experience with it previously.

Please, give me a little bit more time to check everything is alright (at first glance, it seems so). I will post back soon!

@kieran-ryan
Copy link
Contributor Author

kieran-ryan commented Dec 29, 2025

Hi, @kieran-ryan ! Thank you for this PR. I was thinking about switching to ruff myself. I had some positive experience with it previously.

Please, give me a little bit more time to check everything is alright (at first glance, it seems so). I will post back soon!

Yeps absolutely @delatrie, much appreciated!

I've applied the same within other Python test frameworks and tooling and have similarly found a positive experience.

I've aimed for parity with this pull request, though I would like to raise a subsequent merge request for review to extend to further capabilities of ruff - which is where we see the larger benefit in terms of formatting, code quality improvements, updating to later language syntax, catching bugs, etc.

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