Skip to content

Commit 691765f

Browse files
ArnoutDbouwew
authored andcommitted
ruff check --fix
1 parent 8323ff2 commit 691765f

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

plugwise_usb/nodes/sed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ async def set_awake_duration(self, seconds: int) -> bool:
239239

240240
if self._battery_config.awake_duration == seconds:
241241
return False
242-
242+
243243
self._new_battery_config = replace(
244244
self._new_battery_config, awake_duration=seconds
245245
)

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ lint.select = [
258258
"S316", # suspicious-xml-expat-builder-usage
259259
"S317", # suspicious-xml-sax-usage
260260
"S318", # suspicious-xml-mini-dom-usage
261-
"S319", # suspicious-xml-pull-dom-usage
262-
"S320", # suspicious-xmle-tree-usage
261+
"S319", # suspicious-xml-pull-dom-usag
263262
"S601", # paramiko-call
264263
"S602", # subprocess-popen-with-shell-equals-true
265264
"S604", # call-with-shell-equals-true
@@ -278,15 +277,17 @@ lint.select = [
278277
"TID251", # Banned imports
279278
"TRY004", # Prefer TypeError exception for invalid type
280279
# "TRY200", # TRY200 has been remapped to B904
281-
"TRY302", # Remove exception handler; error is immediately re-raised
280+
"TRY203", # Remove exception handler; error is immediately re-raised
282281
"UP", # pyupgrade
283282
"W", # pycodestyle
284283
]
285284

286285
lint.ignore = [
287286
"D202", # No blank lines allowed after function docstring
288287
"D203", # 1 blank line required before class docstring
288+
"D205", # 1 blank line required between summary line and description
289289
"D213", # Multi-line docstring summary should start at the second line
290+
"D401", # First line of docstring should be in imperative mood
290291
"D406", # Section name should end with a newline
291292
"D407", # Section name underlining
292293
"E501", # line too long

tests/test_usb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ async def test_stick_node_discovered_subscription(
590590
)
591591
assert stick.nodes["5555555555555555"].node_info.version == "080007"
592592
assert stick.nodes["5555555555555555"].node_info.model == "Scan"
593-
assert stick.nodes["5555555555555555"].node_info.model_type == None
593+
assert stick.nodes["5555555555555555"].node_info.model_type is None
594594
assert stick.nodes["5555555555555555"].available
595595
assert stick.nodes["5555555555555555"].node_info.is_battery_powered
596596
assert sorted(stick.nodes["5555555555555555"].features) == sorted(
@@ -1147,7 +1147,7 @@ def test_pulse_collection_consumption(
11471147
# Collected pulses last day:
11481148
assert tst_consumption.collected_pulses(
11491149
test_timestamp - td(hours=24), is_consumption=True
1150-
) == (45 + 22861, pulse_update_4)
1150+
) == (45 + 22861, pulse_update_4)
11511151
# pulse-count of 2500 is ignored, the code does not export this incorrect value
11521152

11531153
tst_consumption.add_log(100, 2, (fixed_this_hour + td(hours=1)), 2222)
@@ -2572,7 +2572,7 @@ async def test_node_discovery_and_load(
25722572
)
25732573
assert stick.nodes["5555555555555555"].node_info.version == "080007"
25742574
assert stick.nodes["5555555555555555"].node_info.model == "Scan"
2575-
assert stick.nodes["5555555555555555"].node_info.model_type == None
2575+
assert stick.nodes["5555555555555555"].node_info.model_type is None
25762576
assert stick.nodes["5555555555555555"].available
25772577
assert stick.nodes["5555555555555555"].node_info.is_battery_powered
25782578
assert sorted(stick.nodes["5555555555555555"].features) == sorted(
@@ -2637,7 +2637,7 @@ async def test_node_discovery_and_load(
26372637
)
26382638
assert stick.nodes["8888888888888888"].node_info.version == "070051"
26392639
assert stick.nodes["8888888888888888"].node_info.model == "Switch"
2640-
assert stick.nodes["8888888888888888"].node_info.model_type == None
2640+
assert stick.nodes["8888888888888888"].node_info.model_type is None
26412641
assert stick.nodes["8888888888888888"].available
26422642
assert stick.nodes["8888888888888888"].node_info.is_battery_powered
26432643
assert sorted(stick.nodes["8888888888888888"].features) == sorted(

0 commit comments

Comments
 (0)