From 1cc914f914857cd28c9fc38720de6d401b18a3fd Mon Sep 17 00:00:00 2001 From: zigpy-review-bot <286747149+zigpy-review-bot@users.noreply.github.com> Date: Mon, 28 Sep 2026 02:53:05 +0200 Subject: [PATCH 1/2] Fix ruff target version and mypy pre-commit hook - ruff target-version py39 -> py312, matching requires-python = ">=3.12". Newer ruff rejects the existing `match` statement as invalid syntax under py39. - Run the local mypy hook with `--group testing`: mypy lives in that dependency group, so `uv run --frozen mypy` failed to spawn in a venv synced without it. - Bump ruff-pre-commit v0.6.2 -> v0.16.9 (hook id `ruff` -> `ruff-check`) and codespell v2.3.0 -> v2.4.3. --- .pre-commit-config.yaml | 8 ++++---- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fbcab56..fc5a39b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.2 + rev: v0.16.9 hooks: - - id: ruff + - id: ruff-check args: ["--fix", "--exit-non-zero-on-fix", "--config", "pyproject.toml"] - id: ruff-format args: ["--config", "pyproject.toml"] - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.3 hooks: - id: codespell additional_dependencies: [tomli] @@ -18,7 +18,7 @@ repos: hooks: - id: mypy name: mypy - entry: uv run --frozen mypy + entry: uv run --frozen --group testing mypy language: system types_or: [python, pyi] require_serial: true diff --git a/pyproject.toml b/pyproject.toml index dada0a7..ffaf35c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,7 @@ asyncio_default_fixture_loop_scope = "function" [tool.ruff] required-version = ">=0.5.0" -target-version = "py39" +target-version = "py312" line-length = 88 exclude = [ From 90bd0272b44b8337c34ed89aae1b109adfaec34b Mon Sep 17 00:00:00 2001 From: zigpy-review-bot <286747149+zigpy-review-bot@users.noreply.github.com> Date: Mon, 28 Sep 2026 02:53:05 +0200 Subject: [PATCH 2/2] Apply ruff fixes and formatting for the new target UP017 (`timezone.utc` -> `UTC`) from the py312 target, and ruff 0.16's parenthesized multi-line lambda bodies. No behaviour change. --- zigpy_ziggurat/zigbee/application.py | 9 ++++----- zigpy_ziggurat/zigbee/wire.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/zigpy_ziggurat/zigbee/application.py b/zigpy_ziggurat/zigbee/application.py index 8bb7989..5b914aa 100644 --- a/zigpy_ziggurat/zigbee/application.py +++ b/zigpy_ziggurat/zigbee/application.py @@ -2,7 +2,7 @@ import asyncio from collections.abc import AsyncGenerator -from datetime import datetime, timedelta, timezone +from datetime import UTC, datetime, timedelta import logging import math import os @@ -156,7 +156,7 @@ async def start_network(self) -> None: url ) - self._start_time = datetime.now(timezone.utc) + self._start_time = datetime.now(UTC) def _register_coordinator_device(self) -> None: coordinator = ZigguratCoordinator( @@ -435,7 +435,7 @@ async def _packet_capture( ): packet = cast(p.CapturedPacket, packet) yield t.CapturedPacket( - timestamp=datetime.now(timezone.utc), + timestamp=datetime.now(UTC), rssi=packet.rssi, lqi=packet.lqi, channel=packet.channel, @@ -868,8 +868,7 @@ async def send_packet(self, packet: t.ZigbeePacket) -> None: # stack to reduce routing congestion if device is not None and ( self._start_time is None - or datetime.now(timezone.utc) - self._start_time - < ROUTE_HINT_DURATION + or datetime.now(UTC) - self._start_time < ROUTE_HINT_DURATION ): maybe_relays = self.build_source_route_to(device) diff --git a/zigpy_ziggurat/zigbee/wire.py b/zigpy_ziggurat/zigbee/wire.py index 6b45221..c337ba2 100644 --- a/zigpy_ziggurat/zigbee/wire.py +++ b/zigpy_ziggurat/zigbee/wire.py @@ -272,12 +272,16 @@ class SendUnicastPayload(t.Struct): priority: t.int8s route: RouteControl next_hop: t.NWK = t.StructField( # type: ignore[assignment] - requires=lambda s: cast(SendUnicastPayload, s).route - in (RouteControl.HINT_NEXT_HOP, RouteControl.FORCE_NEXT_HOP) + requires=lambda s: ( + cast(SendUnicastPayload, s).route + in (RouteControl.HINT_NEXT_HOP, RouteControl.FORCE_NEXT_HOP) + ) ) relays: SourceRouteRelays = t.StructField( # type: ignore[assignment] - requires=lambda s: cast(SendUnicastPayload, s).route - in (RouteControl.HINT_SOURCE_ROUTE, RouteControl.FORCE_SOURCE_ROUTE) + requires=lambda s: ( + cast(SendUnicastPayload, s).route + in (RouteControl.HINT_SOURCE_ROUTE, RouteControl.FORCE_SOURCE_ROUTE) + ) ) asdu: t.LongOctetString