Skip to content

Commit 0c81427

Browse files
committed
Add more typing, cosmetics
1 parent 0d24833 commit 0c81427

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

plugwise/helper.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ async def _request(
244244
headers: dict[str, str] = None,
245245
) -> etree:
246246
"""Get/put/delete data from a give URL."""
247-
resp: ClientResponse = None
247+
resp: ClientResponse | None = None
248248
url: str = f"{self._endpoint}{command}"
249249

250250
try:
@@ -264,13 +264,13 @@ async def _request(
264264
)
265265
except ServerTimeoutError:
266266
if retry < 1:
267-
LOGGER.error("Timed out sending command to Plugwise: %s", command)
267+
LOGGER.error("Timed out sending %s command to Plugwise", command)
268268
raise DeviceTimeoutError
269269
return await self._request(command, retry - 1)
270270

271271
return await self._request_validate(resp, method)
272272

273-
async def close_connection(self):
273+
async def close_connection(self) -> ClientSession:
274274
"""Close the Plugwise connection."""
275275
await self._websession.close()
276276

@@ -313,7 +313,7 @@ def _locations_legacy(self) -> None:
313313
"""Helper-function for _all_locations().
314314
Create locations for legacy devices.
315315
"""
316-
appliances = set()
316+
appliances: set = set()
317317
self._home_location = FAKE_LOC
318318

319319
# Add Anna appliances
@@ -398,7 +398,7 @@ def _get_module_data(self, appliance, locator, mod_type) -> list[str | None]:
398398
"""Helper-function for _energy_device_info_finder() and _appliance_info_finder().
399399
Collect requested info from MODULES.
400400
"""
401-
appl_search = appliance.find(locator)
401+
appl_search: etree | None = appliance.find(locator)
402402
if appl_search is not None:
403403
link_id: str = appl_search.attrib["id"]
404404
locator: str = f".//{mod_type}[@id='{link_id}']...."
@@ -424,7 +424,7 @@ def _energy_device_info_finder(self, appliance, appl) -> Munch:
424424
if appl.model != "Switchgroup":
425425
appl.model = None
426426
if module_data[2] is not None:
427-
hw_version = module_data[2].replace("-", "")
427+
hw_version: str = module_data[2].replace("-", "")
428428
appl.model = version_to_model(hw_version)
429429
appl.fw = module_data[3]
430430
return appl
@@ -573,14 +573,16 @@ def _all_appliances(self) -> None:
573573
)
574574

575575
# The presence of either indicates a local active device, e.g. heat-pump or gas-fired heater
576-
ch_state: etree | None = self._appliances.find(
576+
c_heating_state: etree | None = self._appliances.find(
577577
".//logs/point_log[type='central_heating_state']"
578578
)
579579
ot_fault_code: etree | None = self._appliances.find(
580580
".//logs/point_log[type='open_therm_oem_fault_code']"
581581
)
582-
self._opentherm_device = ch_state is not None and ot_fault_code is not None
583-
self._on_off_device = ch_state is not None and ot_fault_code is None
582+
self._opentherm_device = (
583+
c_heating_state is not None and ot_fault_code is not None
584+
)
585+
self._on_off_device = c_heating_state is not None and ot_fault_code is None
584586

585587
for appliance in self._appliances.findall("./appliance"):
586588
appl: Munch = Munch()

0 commit comments

Comments
 (0)