Description
Following a comment in #3420 review, I've collected a range of ruff
rules, to propose adopting in altair
.
This is an opinionated list, with a focus on rules providing an autofix (ruff check . --fix
) - to limit any extra work removing warnings.
I think the ruff
docs do a great job explaining each rule, so I've kept my additional notes brief. Strongly recommend checking out rules marked with a 🛠️ for examples of the change they would make.
Also, if accepted, I would suggest introducing any new rules close to a new release - since this would very likely create a large diff, especially if all of these were added at once.
flake8-simplify (SIM)
- Majority have autofixes
- First mentioned in #3420 review
pydocstyle (D)
- Majority have autofixes
- I haven't come across any
altair
specific doc conventions - A starting point could be the config below and then tweaking
DXXX
rules from there - See docstring-formatting for sample output
[tool.ruff.format]
docstring-code-format=true
docstring-code-line-length=72
[tool.ruff.lint]
pycodestyle={ max-doc-length=88 }
pydocstyle={ convention="numpy" }
pyupgrade (UP)
- All have autofixes and respect
tool.ruff.target-version
- Really helpful considering altair 1.0.0 targeted
python>=2.7,<3.6
- When paired with FA100, the autofixes can help improve readability of annotations - some of which are particularly verbose on
python<3.9
.
flake8-type-checking (TCH)
flake8-errmsg (EM)
- All have autofixes
flake8-pie (PIE)
- All have autofixes, except PIE796
- Found only a single use of
enum
anyway
flake-8-use-pathlib (PTH)
- No autofixes, but most do improve readability
- First mentioned in #3426 commit
Misc
Library-specific
These seem like a good fit, based on the current dependencies however I haven't used them before - unlike all other suggestions:
Preview
These mostly require the opt-in preview mode, with varying degrees of autofixes.