Skip to content

Commit 5474886

Browse files
committed
Added missing typing
-) Added missing typing to changed/added methods -) Moved MyQDevice import to method where it is required.
1 parent b5baf4e commit 5474886

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

pymyq/api.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from aiohttp import ClientSession
77
from aiohttp.client_exceptions import ClientError
88

9-
from .device import MyQDevice
109
from .errors import MyQError, RequestError, UnsupportedBrandError
1110

1211
_LOGGER = logging.getLogger(__name__)
@@ -109,18 +108,18 @@ async def _request(
109108
type_exception, endpoint, err))
110109

111110
_LOGGER.warning('%s for %s; retrying: %s',
112-
type_exception, endpoint, err)
111+
type_exception, endpoint, err)
113112
await asyncio.sleep(5)
114113

115114
_LOGGER.debug('Request to %s completed', url)
116115

117-
async def _update_device_state(self):
116+
async def _update_device_state(self) -> None:
118117
async with self._update_lock:
119118
if datetime.utcnow() - self._last_update >\
120119
MIN_TIME_BETWEEN_UPDATES:
121120
await self._get_device_states()
122121

123-
async def _get_device_states(self):
122+
async def _get_device_states(self) -> bool:
124123
_LOGGER.debug('Retrieving new device states')
125124
try:
126125
devices_resp = await self._request('get', DEVICE_LIST_ENDPOINT)
@@ -136,8 +135,9 @@ async def _get_device_states(self):
136135

137136
self._store_device_states(devices_resp.get('Devices', []))
138137
_LOGGER.debug('New device states retrieved')
138+
return True
139139

140-
def _store_device_states(self, devices):
140+
def _store_device_states(self, devices: dict) -> None:
141141
for device in self._devices:
142142
myq_device = next(
143143
(element for element in devices
@@ -168,6 +168,8 @@ async def authenticate(self, username: str, password: str) -> None:
168168

169169
async def get_devices(self, covers_only: bool = True) -> list:
170170
"""Get a list of all devices associated with the account."""
171+
from .device import MyQDevice
172+
171173
_LOGGER.debug('Retrieving list of devices')
172174
devices_resp = await self._request('get', DEVICE_LIST_ENDPOINT)
173175
# print(json.dumps(devices_resp, indent=4))

pymyq/device.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime, timedelta
44
from typing import Union
55

6+
from .api import API
67
from .errors import RequestError
78

89
_LOGGER = logging.getLogger(__name__)
@@ -35,7 +36,7 @@
3536
class MyQDevice:
3637
"""Define a generic MyQ device."""
3738

38-
def __init__(self, device: dict, brand: str, api) -> None:
39+
def __init__(self, device: dict, brand: str, api: API) -> None:
3940
"""Initialize."""
4041
self._brand = brand
4142
self._device = device

0 commit comments

Comments
 (0)