Skip to content

Replace black with ruff format and align the ruff config - #64

Draft
zigpy-review-bot wants to merge 2 commits into
zigpy:devfrom
zigpy-review-bot:zigpy-bot/migrate-to-ruff
Draft

zigpy-review-bot wants to merge 2 commits into
zigpy:devfrom
zigpy-review-bot:zigpy-bot/migrate-to-ruff

Conversation

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator

Changes

  • black 23.1.0 → ruff format. ruff-pre-commit v0.0.246 → v0.16.9, with the repo URL moved from charliermarsh/ to astral-sh/ and the hook ids ruff-check / ruff-format.
  • [tool.ruff] moves to the current [tool.ruff.lint] layout. The rules go from F, E, W, I001 to B, C, E, F, I, SIM, UP, W, the set zigpy-znp uses, with max-complexity = 25. isort now uses force-sort-within-sections and combine-as-imports like the other zigpy libraries. target-version = "py311" matches requires-python.
  • Second commit: the resulting fixes. ruff fixed the import order and SIM300 (a reversed comparison), and ruff format joined an implicitly concatenated log format string. By hand: SIM108 (if/else → ternary, which ruff marks as an unsafe fix) and dropping the parentheses left around the joined string. No behaviour change.

Verification

  • pre-commit run --all-files passes on Python 3.14.
  • Tests: 7 passed.
  • zigpy --help still lists the db, ota, pcap and radio commands after the import reordering in __main__.py.

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.

Import sorting (force-sort-within-sections, as in the other zigpy libraries), SIM300 and SIM108, and ruff format joining an implicitly concatenated log format string. No behaviour change.
@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.64%. Comparing base (d5de026) to head (90f3508).
⚠️ Report is 2 commits behind head on dev.

Files with missing lines Patch % Lines
zigpy_cli/radio.py 0.00% 2 Missing ⚠️
zigpy_cli/__main__.py 0.00% 1 Missing ⚠️
zigpy_cli/database.py 0.00% 1 Missing ⚠️
zigpy_cli/ota.py 0.00% 1 Missing ⚠️
zigpy_cli/pcap.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             dev     #64      +/-   ##
========================================
+ Coverage   7.61%   7.64%   +0.02%     
========================================
  Files          9       9              
  Lines        617     615       -2     
========================================
  Hits          47      47              
+ Misses       570     568       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zigpy-review-bot zigpy-review-bot added the code quality Improvement to code quality label Oct 10, 2026
@zigpy-review-bot zigpy-review-bot added the bot-watch: fix zigpy-review-bot follows this thread and also pushes fixes (review + fix) label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-watch: fix zigpy-review-bot follows this thread and also pushes fixes (review + fix) code quality Improvement to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant