Skip to content

Commit 5fe6eb2

Browse files
committed
More typing
1 parent 70619d8 commit 5fe6eb2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

plugwise/smile.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Use of this source code is governed by the MIT license found in the LICENSE file.
22
Plugwise backend module for Home Assistant Core.
33
"""
4-
from typing import Optional
4+
from typing import Any, Optional, Tuple
55

66
import aiohttp
77
from defusedxml import ElementTree as etree
@@ -300,7 +300,7 @@ async def connect(self) -> bool:
300300

301301
return True
302302

303-
async def _smile_detect_legacy(self, result, dsmrmain) -> (str, str):
303+
async def _smile_detect_legacy(self, result, dsmrmain) -> Tuple[str, str]:
304304
"""Helper-function for _smile_detect()."""
305305
network: etree = result.find(".//module/protocols/master_controller")
306306

@@ -387,7 +387,7 @@ async def _smile_detect(self, result, dsmrmain) -> None:
387387
self._stretch_v2 = self.smile_version[1].major == 2
388388
self._stretch_v3 = self.smile_version[1].major == 3
389389

390-
async def _full_update_device(self):
390+
async def _full_update_device(self) -> None:
391391
"""Perform a first fetch of all XML data, needed for initialization."""
392392
self._locations = await self._request(LOCATIONS)
393393
self._modules = await self._request(MODULES)
@@ -400,20 +400,20 @@ async def _full_update_device(self):
400400
if self.smile_type != "power":
401401
await self._update_domain_objects()
402402

403-
async def _update_domain_objects(self):
403+
async def _update_domain_objects(self) -> None:
404404
"""Helper-function for smile.py: full_update_device() and async_update().
405405
Request domain_objects data.
406406
"""
407407
self._domain_objects = await self._request(DOMAIN_OBJECTS)
408408

409409
# If Plugwise notifications present:
410410
self._notifications = {}
411-
notifications = self._domain_objects.findall(".//notification")
411+
notifications: etree = self._domain_objects.findall(".//notification")
412412
for notification in notifications:
413413
try:
414-
msg_id = notification.attrib["id"]
415-
msg_type = notification.find("type").text
416-
msg = notification.find("message").text
414+
msg_id: str = notification.attrib["id"]
415+
msg_type: str = notification.find("type").text
416+
msg: str = notification.find("message").text
417417
self._notifications.update({msg_id: {msg_type: msg}})
418418
LOGGER.debug("Plugwise notifications: %s", self._notifications)
419419
except AttributeError: # pragma: no cover
@@ -422,7 +422,7 @@ async def _update_domain_objects(self):
422422
f"{self._endpoint}{DOMAIN_OBJECTS}",
423423
)
424424

425-
async def async_update(self):
425+
async def async_update(self) -> Tuple[dict, dict]:
426426
"""Perform an incremental update for updating the various device states."""
427427
if self.smile_type != "power":
428428
await self._update_domain_objects()
@@ -436,7 +436,7 @@ async def async_update(self):
436436
self.gw_data["notifications"] = self._notifications
437437

438438
for dev_id, dev_dict in self.gw_devices.items():
439-
data = self._get_device_data(dev_id)
439+
data: dict[str, Any] = self._get_device_data(dev_id)
440440
for key, value in list(data.items()):
441441
if key in dev_dict:
442442
dev_dict[key] = value

0 commit comments

Comments
 (0)