Skip to content

Commit 66c6f91

Browse files
committed
Import annotations, use | None
1 parent fb221b1 commit 66c6f91

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

plugwise/smile.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
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 Any, Optional, Tuple
4+
from __future__ import annotations
5+
6+
from typing import Any
57

68
import aiohttp
79
from defusedxml import ElementTree as etree
@@ -266,14 +268,14 @@ def __init__(
266268
SmileData.__init__(self)
267269

268270
self._notifications: dict[str, str] = {}
269-
self.smile_hostname: Optional[str] = None
271+
self.smile_hostname: str | None = None
270272

271273
async def connect(self) -> bool:
272274
"""Connect to Plugwise device and determine its name, type and version."""
273275
names: list[str] = []
274276

275277
result: etree = await self._request(DOMAIN_OBJECTS)
276-
dsmrmain: etree = result.find(".//module/protocols/dsmrmain")
278+
dsmrmain: etree | None = result.find(".//module/protocols/dsmrmain")
277279

278280
vendor_names: list[etree] = result.findall(".//module/vendor_name")
279281
if not vendor_names:
@@ -302,14 +304,14 @@ async def connect(self) -> bool:
302304

303305
return True
304306

305-
async def _smile_detect_legacy(self, result, dsmrmain) -> Tuple[str, str]:
307+
async def _smile_detect_legacy(self, result, dsmrmain) -> tuple[str, str]:
306308
"""Helper-function for _smile_detect()."""
307-
network: etree = result.find(".//module/protocols/master_controller")
309+
network: etree | None = result.find(".//module/protocols/master_controller")
308310

309311
# Assume legacy
310312
self._smile_legacy = True
311313
# Try if it is an Anna, assuming appliance thermostat
312-
anna: etree = result.find('.//appliance[type="thermostat"]')
314+
anna: etree | None = result.find('.//appliance[type="thermostat"]')
313315
# Fake insert version assuming Anna
314316
# couldn't find another way to identify as legacy Anna
315317
version: str = "1.8.0"
@@ -424,7 +426,7 @@ async def _update_domain_objects(self) -> None:
424426
f"{self._endpoint}{DOMAIN_OBJECTS}",
425427
)
426428

427-
async def async_update(self) -> Tuple[dict, dict]:
429+
async def async_update(self) -> tuple[dict, dict]:
428430
"""Perform an incremental update for updating the various device states."""
429431
if self.smile_type != "power":
430432
await self._update_domain_objects()

0 commit comments

Comments
 (0)