Skip to content

Commit e7fd0d9

Browse files
committed
api: Update type checking with use of generic Device type
1 parent 75bf50b commit e7fd0d9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

smartrent/api.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import logging
2-
from typing import TYPE_CHECKING, List, Optional, Union
2+
from typing import TYPE_CHECKING, List, Optional, TypeVar
33

44
import aiohttp
55

6+
from .device import Device
67
from .lock import DoorLock
78
from .sensor import LeakSensor
89
from .switch import BinarySwitch, MultilevelSwitch
@@ -12,9 +13,7 @@
1213
_LOGGER = logging.getLogger(__name__)
1314

1415
if TYPE_CHECKING:
15-
ALL_DEVICE_TYPES = Union[
16-
DoorLock, Thermostat, BinarySwitch, MultilevelSwitch, LeakSensor
17-
]
16+
ALL_DEVICE_TYPES = TypeVar("ALL_DEVICE_TYPES", bound=Device)
1817

1918

2019
class API:
@@ -37,7 +36,7 @@ def __init__(
3736
aiohttp_session: aiohttp.ClientSession = None,
3837
tfa_token=None,
3938
):
40-
self._device_list: List["ALL_DEVICE_TYPES"] = []
39+
self._device_list: List["ALL_DEVICE_TYPES"] = [] # type: ignore
4140
self.client: Client = Client(email, password, aiohttp_session, tfa_token)
4241

4342
async def async_fetch_devices(self):

0 commit comments

Comments
 (0)