Replace all our Python linters with ruff
Categories
(Developer Infrastructure :: Lint and Formatting, task)
Tracking
(firefox113 fixed)
Tracking | Status | |
---|---|---|
firefox113 | --- | fixed |
People
(Reporter: ahal, Assigned: ahal)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
Attachments
(4 files, 2 obsolete files)
Ruff is a newish tool that's making some waves in the Python community. It's written in Rust and can replace a huge number of existing Python tooling. It has some pretty compelling selling points:
Ruff can be used to replace Flake8 (plus a variety of plugins), isort, pydocstyle, yesqa, eradicate, pyupgrade, and autoflake, all while executing tens or hundreds of times faster than any individual tool.
Autofix support, for automatic error correction
Would solve our clunky autopep8
acting as flake8
's "fixer" problem
10-100x faster than existing linters
Our Python linting story is a bit of a mess, and this tool looks like a promising way to collapse all our rules into a single speedy linter. It even supports flake8's per-file-ignores
feature, which means we'd have that capability for things like isort
and pyupgrade
as well!
Comment 1•1 year ago
|
||
ah ah, I was opening a bug for this :)
More info:
https://notes.crmarsh.com/ruff-the-first-200-releases
Assignee | ||
Comment 2•1 year ago
|
||
Since filing this I've used ruff in a few projects and have spent a decent amount of time looking at the docs. I'm convinced this is something we should do. I'm going to see how far I get here without putting too much effort in.
Assignee | ||
Comment 3•1 year ago
|
||
Assignee | ||
Comment 4•1 year ago
|
||
Depends on D172313
Updated•1 year ago
|
Updated•1 year ago
|
Assignee | ||
Comment 5•1 year ago
|
||
This is enabling the PLE and PLC rules across a much larger swatch of the code
base. The PLR and PLW are additionally enabled at the warning level (introduces
~2500 new warnings).
To avoid extraneous changes in people's patches, rules at the warning level are
excluded from --fix.
Depends on D172348
Assignee | ||
Comment 6•1 year ago
|
||
Depends on D172358
Assignee | ||
Comment 7•1 year ago
|
||
Depends on D172359
Assignee | ||
Comment 8•1 year ago
|
||
Depends on D172360
Comment 9•1 year ago
|
||
Comment on attachment 9322565 [details]
WIP: Bug 1811850 - [lint] Enable pyupgrade rules in ruff, r#linter-reviewers
Revision D172360 was moved to bug 1715287. Setting attachment 9322565 [details] to obsolete.
Comment 10•1 year ago
|
||
Comment on attachment 9322566 [details]
WIP: Bug 1811850 - [lint] Fix pyupgrade lint errors from new configuration, r#linter-reviewers
Revision D172361 was moved to bug 1715287. Setting attachment 9322566 [details] to obsolete.
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 11•1 year ago
|
||
Pushed by ahalberstadt@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c3b0f9666183 [lint] Replace flake8 linter with ruff, r=linter-reviewers,sylvestre https://hg.mozilla.org/integration/autoland/rev/d96f90c2c58b [lint] Replace isort linter with ruff, r=taskgraph-reviewers,linter-reviewers,marco,jcristau https://hg.mozilla.org/integration/autoland/rev/f650123cc188 [lint] Replace pylint linter with ruff, r=linter-reviewers,marco https://hg.mozilla.org/integration/autoland/rev/f8950d716c9e [lint] Fix ruff errors resulting from new configuration, r=webdriver-reviewers,perftest-reviewers,whimboo,sparky,firefox-build-system-reviewers,ahochheiden https://hg.mozilla.org/integration/autoland/rev/e8fcfc7f8108 apply code formatting via Lando
Comment 12•1 year ago
|
||
Backed out for causing linting bustages(bugzilla)
- Backout link
- Push with failures
- Failure Log
- Failure line: FileToBugzillaMappingError: Missing Bugzilla component: pyproject.toml - Set the BUG_COMPONENT in the moz.build file to fix the issue.
Assignee | ||
Updated•1 year ago
|
Comment 13•1 year ago
|
||
Pushed by ahalberstadt@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5dfcd5a1b685 [lint] Replace flake8 linter with ruff, r=linter-reviewers,sylvestre https://hg.mozilla.org/integration/autoland/rev/1f236421121c [lint] Replace isort linter with ruff, r=taskgraph-reviewers,linter-reviewers,marco,jcristau https://hg.mozilla.org/integration/autoland/rev/75ff6a88978b [lint] Replace pylint linter with ruff, r=linter-reviewers,marco https://hg.mozilla.org/integration/autoland/rev/bd79cf7201c7 [lint] Fix ruff errors resulting from new configuration, r=webdriver-reviewers,perftest-reviewers,whimboo,sparky,firefox-build-system-reviewers,ahochheiden
Comment 14•1 year ago
|
||
bugherder |
Comment 15•19 days ago
|
||
This did not replace the formatter we use (black), do we want to replace it too?
Assignee | ||
Comment 16•18 days ago
|
||
Yeah, at the time this was filed Ruff's formatter wasn't ready. But AIUI it is now more or less a drop-in replacement for Black as well. I'm on board with switching, but let's file a new bug.
Description
•