Replace black, isort, flake8 and pyupgrade with ruff - #181
Draft
zigpy-review-bot wants to merge 2 commits into
Draft
zigpy-review-bot wants to merge 2 commits into
zigpy-review-bot wants to merge 2 commits into
Conversation
Autofixes: C420 (dict.fromkeys), SIM910 (dict.get default), SIM103, SIM105 (contextlib.suppress) and lowercase hex escapes from ruff format. By hand: exception chaining for re-raised errors, explicit zip(strict=...) (strict=False where the lengths may differ, keeping the current behaviour), a merged nested `with` statement, and a test that evaluated a property without asserting on it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #181 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 733 730 -3
=========================================
- Hits 733 730 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
The pinned hooks still pass, but they are old: black 23.9.1, isort 5.12.0, ruff v0.0.291, pyupgrade v3.15.0, mypy v1.6.0. The flake8 plugin pins (for example
pycodestyle==2.11.0) also conflict with current flake8, so it cannot be bumped without re-pinning every plugin. This replaces the stack with ruff.ruff-check+ruff-format(ruff-pre-commit v0.16.9) replaceblack,isort,flake8(with its plugins),autoflake,pyupgradeand the old ruff hook.codespellgoes from v2.2.6 to v2.4.3 andmirrors-mypyfrom v1.6.0 to v2.3.1.[tool.isort]and[tool.flake8]become[tool.ruff]. The rules areB, C, E, F, I, SIM, UP, W, the set zigpy-znp uses, plus the families of the flake8 plugins that were installed:D(pep257convention,D202ignored as before),YTTandASYNC.E501stays enforced, as it was under flake8.requirements_test.txt: dropisort,black,flake8andFlake8-pyproject, and pinruff==0.16.9to match the hook.python.json.dict.fromkeys(C420), a redundantdict.getdefault (SIM910),contextlib.suppress(SIM105), simplified boolean returns in tests (SIM103), and lowercase hex escapes from ruff format. By hand: exception chaining for re-raised errors, explicitzip(strict=...)(strict=Falsewhere the lengths may differ, keeping the current behaviour), a merged nestedwithstatement, and a test that evaluated a property without asserting on it.Verification
pre-commit run --all-filespasses on Python 3.14.Context
This is one of a set of draft PRs that align the pre-commit setup of the zigpy libraries on ruff (
ruff check+ruff format), which zigpy, zha, zha-device-handlers, zigpy-znp, zigpy-ota and zigpy-ziggurat already use. The same change is proposed for bellows, zigpy-deconz, zigpy-xbee, zigpy-zigate and zigpy-cli, plus small ruff config fixes in zigpy and zigpy-ziggurat.The commits are kept separate so parts can be dropped or moved into their own PR. Maintainers can ask the bot for that, or for any other change, by commenting
@zigpy-review-bot <request>on this PR.