Skip to content

Commit 7eb1be7

Browse files
committed
CR: Fix list modification during iteration
CR: The type annotation uses incorrect syntax. CR: The registry’s private scan method calls
1 parent e6a37a2 commit 7eb1be7

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

plugwise_usb/network/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,8 @@ async def _discover_stragglers(self) -> None:
434434
"""Repeat Discovery of Nodes with unknown NodeType."""
435435
while len(self._registry_stragglers) > 0:
436436
await sleep(NODE_RETRY_DISCOVER_INTERVAL)
437-
for mac in self._registry_stragglers:
438-
if not await self._discover_node(mac, None):
437+
for mac in list(self._registry_stragglers):
438+
if await self._discover_node(mac, None):
439439
self._registry_stragglers.remove(mac)
440440
_LOGGER.debug(
441441
"Total %s nodes unreachable having unknown NodeType",

plugwise_usb/network/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def get_nodetype(self, mac: str) -> NodeType | None:
7878
"""Return NodeType from cache."""
7979
return self._nodetypes.get(mac)
8080

81-
async def prune_cache(self, registry: list(str)) -> None:
81+
async def prune_cache(self, registry: list[str]) -> None:
8282
"""Remove items from cache which are not found in registry scan."""
8383
_new_nodetypes: dict[str, NodeType] = {}
8484
for mac in registry:

plugwise_usb/network/registry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ def scan_completed(self) -> bool:
9999
"""Indicate if scan is completed."""
100100
return self._scan_completed
101101

102-
def start_node_discover(self, callback: Callable[[], Awaitable[None]]) -> None:
102+
def start_node_discover(
103+
self, callback: Callable[[str, NodeType | None, bool], Awaitable[None]]
104+
) -> None:
103105
"""Register method to be called when a node is found."""
104106
self._start_node_discover = callback
105107

0 commit comments

Comments
 (0)