Skip to content

Commit e59a5f0

Browse files
ArnoutDbouwew
authored andcommitted
ruff check --fix
1 parent b98572a commit e59a5f0

File tree

13 files changed

+38
-18
lines changed

13 files changed

+38
-18
lines changed

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/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
@@ -1263,7 +1263,7 @@ class CircleMeasureIntervalRequest(PlugwiseRequest):
12631263
12641264
FIXME: Make sure production interval is a multiply of consumption !!
12651265
1266-
Response message: NodeResponse with ack-type POWER_LOG_INTERVAL_ACCEPTED
1266+
Response message: NodeResponse with ack-type POWER_LOG_INTERVAL_ACCEPTED
12671267
"""
12681268

12691269
_identifier = b"0057"

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 (
@@ -444,7 +444,7 @@ async def get_missing_energy_logs(self) -> None:
444444
"Start with initial energy request for the last 10 log addresses for node %s.",
445445
self._mac_in_str,
446446
)
447-
447+
448448
total_addresses = int(floor(datetime.now(tz=UTC).hour / 4) + 1)
449449
log_address = self._current_log_address
450450
while total_addresses > 0:

plugwise_usb/nodes/helpers/pulses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import logging
88
from typing import Final
99

10-
from ...constants import LOGADDR_MAX, MINUTE_IN_SECONDS, DAY_IN_HOURS
10+
from ...constants import DAY_IN_HOURS, LOGADDR_MAX, MINUTE_IN_SECONDS
1111
from ...exceptions import EnergyError
1212

1313
_LOGGER = logging.getLogger(__name__)

plugwise_usb/nodes/helpers/subscription.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from dataclasses import dataclass
88
from typing import Any
99

10-
1110
from ...api import NodeFeature
1211

1312

@@ -21,7 +20,13 @@ class NodeFeatureSubscription:
2120

2221
class FeaturePublisher:
2322
"""Base Class to call awaitable of subscription when event happens."""
23+
2424
def __init__(self) -> None:
25+
"""Initializes the instance with an empty dictionary to store feature update subscribers.
26+
27+
The dictionary maps callback functions (Callable[[], None]) to their corresponding
28+
NodeFeatureSubscription objects, allowing management of feature update subscriptions.
29+
"""
2530
self._feature_update_subscribers: dict[
2631
Callable[[], None],
2732
NodeFeatureSubscription,

plugwise_usb/nodes/scan.py

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

5050
# Sensitivity values for motion sensor configuration
5151
SENSITIVITY_HIGH_VALUE = 20 # 0x14
52-
SENSITIVITY_MEDIUM_VALUE = 30 # 0x1E
52+
SENSITIVITY_MEDIUM_VALUE = 30 # 0x1E
5353
SENSITIVITY_OFF_VALUE = 255 # 0xFF
5454

5555
# endregion

0 commit comments

Comments
 (0)