Skip to content

Commit d983bf7

Browse files
committed
ruff check --fix
1 parent da8edab commit d983bf7

File tree

17 files changed

+43
-23
lines changed

17 files changed

+43
-23
lines changed

plugwise_usb/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from collections.abc import Callable, Coroutine
1111
from functools import wraps
1212
import logging
13-
from typing import Any, TypeVar, cast, Final
13+
from typing import Any, Final, TypeVar, cast
1414

1515
from .api import NodeEvent, PlugwiseNode, StickEvent
1616
from .connection import StickController
@@ -295,7 +295,7 @@ async def connect(self, port: str | None = None) -> None:
295295
"Unable to connect. " +
296296
"Path to USB-Stick is not defined, set port property first"
297297
)
298-
298+
299299
await self._controller.connect_to_stick(
300300
self._port,
301301
)

plugwise_usb/connection/manager.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,24 @@ def __init__(self) -> None:
3838

3939
@property
4040
def queue_depth(self) -> int:
41+
"""Calculate and return the current depth of the message queue.
42+
43+
Returns:
44+
int: The number of expected responses that have not yet been processed.
45+
46+
"""
4147
return self._sender.expected_responses - self._receiver.processed_messages
4248

4349
def correct_received_messages(self, correction: int) -> None:
50+
"""Adjusts the count of received messages by applying a correction value.
51+
52+
Args:
53+
correction (int): The number to adjust the processed messages count by. Positive values increase the count, negative values decrease it.
54+
55+
Returns:
56+
None
57+
58+
"""
4459
self._receiver.correct_processed_messages(correction)
4560

4661
@property

plugwise_usb/connection/queue.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ async def stop(self) -> None:
7676

7777
async def submit(self, request: PlugwiseRequest) -> PlugwiseResponse | None:
7878
"""Add request to queue and return the received node-response when applicable.
79-
8079
Raises an error when something fails.
8180
"""
8281
if request.waiting_for_response:

plugwise_usb/connection/sender.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, stick_receiver: StickReceiver, transport: Transport) -> None:
4848
def expected_responses(self) -> int:
4949
"""Return the number of processed messages."""
5050
return self._expected_responses
51-
51+
5252
async def start(self) -> None:
5353
"""Start the sender."""
5454
# Subscribe to ACCEPT stick responses, which contain the seq_id we need.

plugwise_usb/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
# Max timeout in seconds
3333
# Stick responds with timeout messages within 10s.
34-
STICK_TIME_OUT: Final = 11
34+
STICK_TIME_OUT: Final = 11
3535
# In bigger networks a response from a Node could take up a while, so lets use 15 seconds.
3636
NODE_TIME_OUT: Final = 15
3737

plugwise_usb/helpers/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async def initialize_cache(self, create_root_folder: bool = False) -> None:
5959
cache_dir = self._get_writable_os_dir()
6060
await makedirs(cache_dir, exist_ok=True)
6161
self._cache_path = cache_dir
62-
62+
6363
self._cache_file = os_path_join(self._cache_path, self._file_name)
6464
self._cache_file_exists = await ospath.exists(self._cache_file)
6565
self._initialized = True

plugwise_usb/messages/properties.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def serialize(self) -> bytes:
391391
def deserialize(self, val: bytes) -> None:
392392
"""Convert data into integer value based on log address formatted data."""
393393
if val == b"00000000":
394-
self._value = int(0)
394+
self._value = 0
395395
return
396396
Int.deserialize(self, val)
397397
self._value = (self.value - LOGADDR_OFFSET) // 32

plugwise_usb/messages/requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ class CircleMeasureIntervalRequest(PlugwiseRequest):
12641264
12651265
FIXME: Make sure production interval is a multiply of consumption !!
12661266
1267-
Response message: NodeResponse with ack-type POWER_LOG_INTERVAL_ACCEPTED
1267+
Response message: NodeResponse with ack-type POWER_LOG_INTERVAL_ACCEPTED
12681268
"""
12691269

12701270
_identifier = b"0057"

plugwise_usb/network/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
from ..constants import UTF8
1616
from ..exceptions import CacheError, MessageError, NodeError, StickError, StickTimeout
1717
from ..messages.requests import (
18-
CirclePlusAllowJoiningRequest,
1918
CircleMeasureIntervalRequest,
19+
CirclePlusAllowJoiningRequest,
2020
NodePingRequest,
2121
)
2222
from ..messages.responses import (

plugwise_usb/nodes/circle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from asyncio import Task, create_task, gather
66
from collections.abc import Awaitable, Callable
77
from dataclasses import replace
8-
from math import floor
98
from datetime import UTC, datetime
109
from functools import wraps
1110
import logging
11+
from math import floor
1212
from typing import Any, TypeVar, cast
1313

1414
from ..api import (
@@ -447,7 +447,7 @@ async def get_missing_energy_logs(self) -> None:
447447
"Start with initial energy request for the last 10 log addresses for node %s.",
448448
self._mac_in_str,
449449
)
450-
450+
451451
total_addresses = int(floor(datetime.now(tz=UTC).hour / 4) + 1)
452452
log_address = self._current_log_address
453453
while total_addresses > 0:

0 commit comments

Comments
 (0)