From ce3da98fd4b5d99b9339f7a83e8e9951c01a3909 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Mon, 15 Apr 2024 09:43:23 -0400 Subject: [PATCH] Use strict `zip` --- bellows/ash.py | 5 +++-- bellows/types/__init__.py | 2 +- bellows/zigbee/application.py | 4 +++- tests/test_application.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bellows/ash.py b/bellows/ash.py index bd76ffd1..e43d0f6a 100644 --- a/bellows/ash.py +++ b/bellows/ash.py @@ -147,8 +147,9 @@ class DataFrame(AshFrame): @staticmethod def _randomize(data: bytes) -> bytes: - assert len(data) <= len(PSEUDO_RANDOM_DATA_SEQUENCE) - return bytes([a ^ b for a, b in zip(data, PSEUDO_RANDOM_DATA_SEQUENCE)]) + return bytes( + [a ^ b for a, b in zip(data, PSEUDO_RANDOM_DATA_SEQUENCE, strict=True)] + ) @classmethod def from_bytes(cls, data: bytes) -> DataFrame: diff --git a/bellows/types/__init__.py b/bellows/types/__init__.py index 4a25b948..e8a9e552 100644 --- a/bellows/types/__init__.py +++ b/bellows/types/__init__.py @@ -12,4 +12,4 @@ def deserialize(data, schema): def serialize(data, schema): - return b"".join(t(v).serialize() for t, v in zip(schema, data)) + return b"".join(t(v).serialize() for t, v in zip(schema, data, strict=True)) diff --git a/bellows/zigbee/application.py b/bellows/zigbee/application.py index 5b757bf0..2e9b1302 100644 --- a/bellows/zigbee/application.py +++ b/bellows/zigbee/application.py @@ -1000,7 +1000,9 @@ async def _watchdog_feed(self): else: (res,) = await self._ezsp.readAndClearCounters() - for cnt_type, value in zip(self._ezsp.types.EmberCounterType, res): + for cnt_type, value in zip( + self._ezsp.types.EmberCounterType, res, strict=True + ): counters[cnt_type.name[8:]].update(value) if remainder == 0: diff --git a/tests/test_application.py b/tests/test_application.py index 7434e230..acb48a30 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -1592,7 +1592,7 @@ async def test_startup_new_coordinator_no_groups_joined(app, ieee): ) async def test_energy_scanning(app, scan_results): app._ezsp.startScan = AsyncMock( - return_value=list(zip(range(11, 26 + 1), scan_results)) + return_value=list(zip(range(11, 26 + 1), scan_results, strict=True)) ) results = await app.energy_scan(