Repository navigation
Replace black, isort, flake8 and pyupgrade with ruff - #167
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
Mostly autofixes: import sorting, pyupgrade rewrites for the Python 3.11 floor (typing.Dict -> dict, timezone.utc -> UTC, str.format -> f-strings) and ruff format. By hand: remaining %-formatting (struct format strings and __str__ methods) -> f-strings, a %-formatted LOGGER.exception call -> lazy logging arguments, explicit zip(strict=...) keeping the current behaviour, and exception chaining for re-raised errors.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #167 +/- ##
==========================================
+ Coverage 46.46% 46.49% +0.03%
==========================================
Files 8 8
Lines 1300 1299 -1
==========================================
Hits 604 604
+ Misses 696 695 -1 ☔ 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.
Problem
pre-commit can no longer be installed in this repo. The
fsouza/autoflake8hook repository has been deleted from GitHub:The last CI run, in April, passed. The shared workflow installs hooks fresh whenever it has no cached pre-commit environment, and GitHub evicts caches that go unused for 7 days, so the next CI run will fail the same way.
Changes
black,flake8(with its plugin pins),isort,pyupgradeandautoflake8in favour ofruff-check+ruff-format(ruff-pre-commit v0.16.9).debug-statementsstays;mirrors-mypygoes from v1.20.1 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, withmax-complexity = 25, plusYTTbecauseflake8-2020was installed.E501stays ignored and thetests/*per-file ignores are unchanged. The isort settings carry over.requirements_test.txt: dropisort,black,flake8andFlake8-pyproject, and bumpruff==0.0.261toruff==0.16.9to match the hook.python.json.typing.Dict→dict,timezone.utc→UTC,str.format→ f-strings). The old pyupgrade hook ran without a--pyXX-plusflag, so these had not been applied. By hand: the remaining%-formatting (struct format strings and__str__methods), a%-formattedLOGGER.exceptioncall → lazy logging arguments, explicitzip(strict=...)keeping the current behaviour, and exception chaining for re-raised errors.Verification
pre-commit run --all-filespasses on Python 3.14. Ondevit fails while installing hooks.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.