Skip to content

Commit

Permalink
Improve typing and annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
denpamusic committed Nov 2, 2023
1 parent 0c73721 commit 0d3c820
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyplumio/helpers/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def set_nowait(self, value: ParameterValueType, retries: int = SET_RETRIES) -> N

@property
def pending_update(self) -> bool:
"""Check if parameter update is confirmed on the device."""
"""Check if parameter is pending update on the device."""
return self._pending_update

@property
Expand Down
10 changes: 4 additions & 6 deletions pyplumio/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import asyncio
from collections.abc import Awaitable, Callable
import logging
from typing import Final
from typing import Final, cast

from pyplumio.const import ATTR_CONNECTED, DeviceType
from pyplumio.devices import Addressable, get_device_handler_and_name
Expand All @@ -14,6 +14,7 @@
ReadError,
UnknownDeviceError,
)
from pyplumio.frames import Frame
from pyplumio.frames.requests import StartMasterRequest
from pyplumio.helpers.event_manager import EventManager
from pyplumio.helpers.factory import factory
Expand Down Expand Up @@ -45,11 +46,10 @@ def __init__(
ethernet_parameters: EthernetParameters | None = None,
wireless_parameters: WirelessParameters | None = None,
):
"""Initialize new Protocol object."""
"""Initialize a new protocol."""
super().__init__()
self.writer = None
self.reader = None
self.data = {}
self.connected = asyncio.Event()
read_queue: asyncio.Queue = asyncio.Queue()
write_queue: asyncio.Queue = asyncio.Queue()
Expand Down Expand Up @@ -97,7 +97,7 @@ async def frame_consumer(self, read_queue: asyncio.Queue) -> None:
"""Handle frame processing."""
await self.connected.wait()
while self.connected.is_set():
device, frame = await read_queue.get()
device, frame = cast(tuple[Addressable, Frame], await read_queue.get())
device.handle_frame(frame)
read_queue.task_done()

Expand Down Expand Up @@ -134,7 +134,6 @@ async def shutdown(self):
"""Shutdown protocol tasks."""
await asyncio.gather(*[queue.join() for queue in self.queues])
await super().shutdown()

for device in self.data.values():
await device.shutdown()

Expand All @@ -143,7 +142,6 @@ async def shutdown(self):
def setup_device_entry(self, device_type: DeviceType) -> Addressable:
"""Setup the device entry."""
handler, name = get_device_handler_and_name(device_type)

if name not in self.data:
self._create_device_entry(name, handler)

Expand Down

0 comments on commit 0d3c820

Please sign in to comment.