15
15
import logging
16
16
import struct
17
17
from pprint import pformat as pf
18
- from typing import Dict , Optional , Union
18
+ from typing import Dict , Generator , Optional , Union
19
19
20
20
from .exceptions import SmartDeviceException
21
21
@@ -107,7 +107,7 @@ async def _execute_query(self, request: str) -> Dict:
107
107
108
108
return json_payload
109
109
110
- async def close (self ):
110
+ async def close (self ) -> None :
111
111
"""Close the connection."""
112
112
writer = self .writer
113
113
self .reader = self .writer = None
@@ -116,7 +116,7 @@ async def close(self):
116
116
with contextlib .suppress (Exception ):
117
117
await writer .wait_closed ()
118
118
119
- def _reset (self ):
119
+ def _reset (self ) -> None :
120
120
"""Clear any varibles that should not survive between loops."""
121
121
self .reader = self .writer = self .loop = self .query_lock = None
122
122
@@ -154,13 +154,13 @@ async def _query(self, request: str, retry_count: int, timeout: int) -> Dict:
154
154
await self .close ()
155
155
raise SmartDeviceException ("Query reached somehow to unreachable" )
156
156
157
- def __del__ (self ):
157
+ def __del__ (self ) -> None :
158
158
if self .writer and self .loop and self .loop .is_running ():
159
159
self .writer .close ()
160
160
self ._reset ()
161
161
162
162
@staticmethod
163
- def _xor_payload (unencrypted ) :
163
+ def _xor_payload (unencrypted : bytes ) -> Generator [ int , None , None ] :
164
164
key = TPLinkSmartHomeProtocol .INITIALIZATION_VECTOR
165
165
for unencryptedbyte in unencrypted :
166
166
key = key ^ unencryptedbyte
@@ -179,7 +179,7 @@ def encrypt(request: str) -> bytes:
179
179
)
180
180
181
181
@staticmethod
182
- def _xor_encrypted_payload (ciphertext ) :
182
+ def _xor_encrypted_payload (ciphertext : bytes ) -> Generator [ int , None , None ] :
183
183
key = TPLinkSmartHomeProtocol .INITIALIZATION_VECTOR
184
184
for cipherbyte in ciphertext :
185
185
plainbyte = key ^ cipherbyte
0 commit comments