@@ -72,7 +72,16 @@ class WrtDevice(NamedTuple):
7272
7373_LOGGER = logging .getLogger (__name__ )
7474
75- type _FuncType [_T ] = Callable [[_T ], Awaitable [list [Any ] | tuple [Any ] | dict [str , Any ]]]
75+ type _FuncType [_T ] = Callable [
76+ [_T ],
77+ Awaitable [
78+ list [str ]
79+ | tuple [float | None , float | None ]
80+ | list [float ]
81+ | dict [str , float | str | None ]
82+ | dict [str , float ]
83+ ],
84+ ]
7685type _ReturnFuncType [_T ] = Callable [[_T ], Coroutine [Any , Any , dict [str , Any ]]]
7786
7887
@@ -87,7 +96,9 @@ def _handle_errors_and_zip(
8796 """Run library methods and zip results or manage exceptions."""
8897
8998 @functools .wraps (func )
90- async def _wrapper (self : _AsusWrtBridgeT ) -> dict [str , str ]:
99+ async def _wrapper (
100+ self : _AsusWrtBridgeT ,
101+ ) -> dict [str , float | str | None ] | dict [str , float ]:
91102 try :
92103 data = await func (self )
93104 except exceptions as exc :
@@ -313,22 +324,22 @@ async def _get_available_temperature_sensors(self) -> list[str]:
313324 return [SENSORS_TEMPERATURES_LEGACY [i ] for i in range (3 ) if availability [i ]]
314325
315326 @handle_errors_and_zip ((IndexError , OSError , ValueError ), SENSORS_BYTES )
316- async def _get_bytes (self ) -> Any :
327+ async def _get_bytes (self ) -> tuple [ float | None , float | None ] :
317328 """Fetch byte information from the router."""
318329 return await self ._api .async_get_bytes_total ()
319330
320331 @handle_errors_and_zip ((IndexError , OSError , ValueError ), SENSORS_RATES )
321- async def _get_rates (self ) -> Any :
332+ async def _get_rates (self ) -> tuple [ float , float ] :
322333 """Fetch rates information from the router."""
323334 return await self ._api .async_get_current_transfer_rates ()
324335
325336 @handle_errors_and_zip ((IndexError , OSError , ValueError ), SENSORS_LOAD_AVG )
326- async def _get_load_avg (self ) -> Any :
337+ async def _get_load_avg (self ) -> list [ float ] :
327338 """Fetch load average information from the router."""
328339 return await self ._api .async_get_loadavg ()
329340
330341 @handle_errors_and_zip ((OSError , ValueError ), None )
331- async def _get_temperatures (self ) -> Any :
342+ async def _get_temperatures (self ) -> dict [ str , float ] :
332343 """Fetch temperatures information from the router."""
333344 return await self ._api .async_get_temperature ()
334345
0 commit comments