1212import secrets
1313import struct
1414import time
15+ from collections .abc import Callable , Coroutine
1516from random import randint
16- from typing import Any , Callable , Coroutine , Optional , Type , TypeVar , final
17+ from typing import Any , TypeVar , final
1718
1819import aiohttp
1920
@@ -89,7 +90,7 @@ def md5hex(message: str) -> str:
8990
9091
9192class PreparedRequest :
92- def __init__ (self , base_url : str , base_headers : Optional [ dict ] = None ) -> None :
93+ def __init__ (self , base_url : str , base_headers : dict | None = None ) -> None :
9394 self .base_url = base_url
9495 self .base_headers = base_headers or {}
9596
@@ -251,7 +252,7 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None:
251252 data_protocol = RoborockDataProtocol (int (data_point_number ))
252253 self ._logger .debug (f"Got device update for { data_protocol .name } : { data_point } " )
253254 if data_protocol in ROBOROCK_DATA_STATUS_PROTOCOL :
254- _cls : Type [Status ] = ModelStatus .get (
255+ _cls : type [Status ] = ModelStatus .get (
255256 self .device_info .model , S7MaxVStatus
256257 ) # Default to S7 MAXV if we don't have the data
257258 if self .cache [CacheableAttribute .status ].value is None :
@@ -301,7 +302,7 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None:
301302 except Exception as ex :
302303 self ._logger .exception (ex )
303304
304- def on_connection_lost (self , exc : Optional [ Exception ] ) -> None :
305+ def on_connection_lost (self , exc : Exception | None ) -> None :
305306 self ._last_disconnection = self .time_func ()
306307 self ._logger .info ("Roborock client disconnected" )
307308 if exc is not None :
@@ -340,7 +341,7 @@ def _async_response(
340341 def _get_payload (
341342 self ,
342343 method : RoborockCommand ,
343- params : Optional [ list | dict ] = None ,
344+ params : list | dict | None = None ,
344345 secured = False ,
345346 ):
346347 timestamp = math .floor (time .time ())
@@ -372,16 +373,16 @@ async def send_message(self, roborock_message: RoborockMessage):
372373 async def _send_command (
373374 self ,
374375 method : RoborockCommand ,
375- params : Optional [ list | dict ] = None ,
376+ params : list | dict | None = None ,
376377 ):
377378 raise NotImplementedError
378379
379380 @final
380381 async def send_command (
381382 self ,
382383 method : RoborockCommand ,
383- params : Optional [ list | dict ] = None ,
384- return_type : Optional [ Type [ RT ]] = None ,
384+ params : list | dict | None = None ,
385+ return_type : type [ RT ] | None = None ,
385386 ) -> RT :
386387 cacheable_attribute_result = find_cacheable_attribute (method )
387388
@@ -404,7 +405,7 @@ async def send_command(
404405 return response
405406
406407 async def get_status (self ) -> Status | None :
407- _cls : Type [Status ] = ModelStatus .get (
408+ _cls : type [Status ] = ModelStatus .get (
408409 self .device_info .model , S7MaxVStatus
409410 ) # Default to S7 MAXV if we don't have the data
410411 return _cls .from_dict (await self .cache [CacheableAttribute .status ].async_value ())
0 commit comments