Skip to content

Commit 723d2ca

Browse files
committed
lazy formatting
1 parent 9618258 commit 723d2ca

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

pyhilo/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __init__(self, **event: dict[str, Any]):
6767

6868
def update_wh(self, used_wH: float) -> None:
6969
"""This function is used to update the used_kWh attribute during a Hilo Challenge Event"""
70-
LOG.debug(f"Updating Wh: {used_wH}")
70+
LOG.debug("Updating Wh: %s", used_wH)
7171
self.used_kWh = round(used_wH / 1000, 2)
7272
self.last_update = datetime.now(timezone.utc).astimezone()
7373

pyhilo/graphql.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,14 +562,16 @@ async def subscribe_to_device_updated(
562562
query, variable_values={"locationHiloId": location_hilo_id}
563563
):
564564
LOG.debug(
565-
f"subscribe_to_device_updated: Received subscription result {result}"
565+
"subscribe_to_device_updated: Received subscription result %s",
566+
result,
566567
)
567568
device_hilo_id = self._handle_device_subscription_result(result)
568569
if callback:
569570
callback(device_hilo_id)
570571
except Exception as e:
571572
LOG.debug(
572-
f"subscribe_to_device_updated: Connection lost: {e}. Reconnecting in 5 seconds..."
573+
"subscribe_to_device_updated: Connection lost: %s. Reconnecting in 5 seconds...",
574+
e,
573575
)
574576
await asyncio.sleep(5)
575577
try:
@@ -580,7 +582,8 @@ async def subscribe_to_device_updated(
580582

581583
except Exception as e2:
582584
LOG.error(
583-
f"subscribe_to_device_updated, exception while reconnecting, retrying: {e2}"
585+
"subscribe_to_device_updated, exception while reconnecting, retrying: %s",
586+
e2,
584587
)
585588

586589
async def subscribe_to_location_updated(
@@ -597,7 +600,7 @@ async def subscribe_to_location_updated(
597600
async for result in session.subscribe(
598601
query, variable_values={"locationHiloId": location_hilo_id}
599602
):
600-
LOG.debug(f"Received subscription result {result}")
603+
LOG.debug("Received subscription result %s", result)
601604
device_hilo_id = self._handle_location_subscription_result(result)
602605
callback(device_hilo_id)
603606
except asyncio.CancelledError:
@@ -620,13 +623,13 @@ def _handle_device_subscription_result(self, result: Dict[str, Any]) -> str:
620623
attributes = self.mapper.map_device_subscription_values(devices_values)
621624
updated_device = self._devices.parse_values_received(attributes)
622625
# callback to update the device in the UI
623-
LOG.debug(f"Device updated: {updated_device}")
626+
LOG.debug("Device updated: %s", updated_device)
624627
return devices_values.get("hiloId")
625628

626629
def _handle_location_subscription_result(self, result: Dict[str, Any]) -> str:
627630
devices_values: list[any] = result["onAnyLocationUpdated"]["location"]
628631
attributes = self.mapper.map_location_subscription_values(devices_values)
629632
updated_device = self._devices.parse_values_received(attributes)
630633
# callback to update the device in the UI
631-
LOG.debug(f"Device updated: {updated_device}")
634+
LOG.debug("Device updated: %s", updated_device)
632635
return devices_values.get("hiloId")

0 commit comments

Comments
 (0)