Migrate to ruff
We've thought about migrating to ruff to replace many of our current cluster of linters for a while: mostly for speed, but we've also seen a bug in the unmaintained pydocstyle that would apparently be fixed that way.
Today I ran into another problem: I was going through loose ends from my patches to drop Python 3.11 support and tried to switch to the much nicer PEP 695 syntax for generics, but found that it confuses pydocstyle into thinking that anything using that syntax is undocumented.
I have most of a branch to switch to ruff. There are a few things worth discussing at least briefly first, because while it's possible to get pretty close to our current linting options, we can't have a perfect match.
- There isn't really an equivalent of
flake8-rst-docstrings. I'm inclined to chalk that up to "we don't care all that much", andruff's docstring linting will most likely improve over time anyway. -
U100andU101fromflake8-unused-argumentsare replaced by severalARG*codes. To avoid causing problems for people withflake8editor integration, I suggest that we add appropriatenoqa: ARG*suppressions alongside the existingnoqa: U*(so we'd havenoqa: ARG002, U100or similar), and either let thenoqa: U*suppressions wither naturally over time or remove them in bulk at some later date. - We can switch linting and formatting in different steps, and I think we should.
ruff's formatter nearly matchesblack, but there are various intentional differences. - People with
flake8/black/etc. editor integration might need to adjust slightly. I haven't really looked into the details yet, but ALE (forvim/neovim) supportsruff, so it shouldn't be too difficult and will probably be faster. - I'm inclined to do this in a few steps, first updating
noqacomments and such, then adding therufflinter and removing superseded linters, then switching to theruffformatter. - Once we've switched, it will probably be worth seeing if there are any other rules we can enable to cheaply ratchet up our static analysis. There's quite an interesting menu.
Any other thoughts or objections?
Edited by Colin Watson