chore: migrate from flake8/isort/black/pyupgrade to ruff#38
Conversation
Replace flake8 (with bugbear, comprehensions, typing-as-t plugins), isort, and black pre-commit hooks with ruff lint and format hooks. - Remove .flake8 config file - Replace [tool.isort] with [tool.ruff] config in pyproject.toml - Map flake8 plugin rules to ruff select categories (B, C4, I, TCH) - Ignore E203 for black/ruff-format compat - Fix known-first-party from stale 'mddj' to 'dependency_groups' Assisted-by: OpenCode:glm-5
Remove pyupgrade pre-commit hook in favor of ruff's UP (pyupgrade) rule category. Set target-version = "py39" to match the previous --py39-plus behavior. Assisted-by: OpenCode:glm-5
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Assisted-by: OpenCode:glm-5.1 Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
sirosen
left a comment
There was a problem hiding this comment.
I just realized that this is still open! I thought we merged it during PyCon US, whoops! 😓
I noted a couple of very minor tweaks we should make before merging, related to flake8. However, I'm approving to signal that if those are good to apply, you should feel free to merge afterwards. 🙂
It also highlighted for me that we don't have CI setup for pre-commit. I thought I had configured pre-commit.ci, but it didn't run on this, so maybe I'm mistaken. I'll file an issue for that.
| [flake8] | ||
| exclude = .git,.tox,__pycache__,.eggs,dist,.venv* | ||
| max-line-length = 88 | ||
| extend-ignore = W503,W504,E203 |
There was a problem hiding this comment.
Because flake8 left and came back, we need to restore this file. Otherwise, flake8 fails.
| rev: 5.13.2 | ||
| hooks: | ||
| - id: isort | ||
| additional_dependencies: [flake8-typing-as-t] |
There was a problem hiding this comment.
Assuming you have no objection, let's restore the previous pin!
| additional_dependencies: [flake8-typing-as-t] | |
| additional_dependencies: ['flake8-typing-as-t==1.0.0'] |
First step, minimal old-tools -> ruff conversion, without adding/changing anything. See #8. I can now run pre-commit locally again. pyupgrade was broken before for me.
Also did pyupgrade, and some hand updates/cleanup (newer ruff follows newer black, this was using black 24, only one small change though).
🤖 Human guided, AI assisted PR (using this skill). AI text below. 🤖
Summary
Replace flake8 (with bugbear, comprehensions, typing-as-t plugins), isort, and black pre-commit hooks with ruff lint and format hooks.
Changes
.flake8config file[tool.isort]with[tool.ruff]config inpyproject.tomlselectcategories:B(bugbear),C4(comprehensions),I(isort),TCH(typing-as-t)E203for ruff-format compat (previouslyextend-ignore)known-first-partyfrom stale"mddj"to"dependency_groups"Assisted-by: OpenCode:glm-5.1
📚 Documentation preview 📚: https://dependency-groups--38.org.readthedocs.build/en/38/