mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-04-28 01:26:25 +00:00
typing
This commit is contained in:
parent
e135289ed7
commit
c076bc72ff
@ -1,6 +1,6 @@
|
|||||||
"""Device creation by type."""
|
"""Device creation by type."""
|
||||||
|
|
||||||
from typing import Optional, Type
|
from typing import Any, Dict, Optional, Type
|
||||||
|
|
||||||
from .credentials import Credentials
|
from .credentials import Credentials
|
||||||
from .device_type import DeviceType
|
from .device_type import DeviceType
|
||||||
@ -68,12 +68,12 @@ async def connect(
|
|||||||
return dev
|
return dev
|
||||||
|
|
||||||
|
|
||||||
def get_device_class_from_info(info: dict) -> Type[SmartDevice]:
|
def get_device_class_from_info(info: Dict[str, Any]) -> Type[SmartDevice]:
|
||||||
"""Find SmartDevice subclass for device described by passed data."""
|
"""Find SmartDevice subclass for device described by passed data."""
|
||||||
if "system" not in info or "get_sysinfo" not in info["system"]:
|
if "system" not in info or "get_sysinfo" not in info["system"]:
|
||||||
raise SmartDeviceException("No 'system' or 'get_sysinfo' in response")
|
raise SmartDeviceException("No 'system' or 'get_sysinfo' in response")
|
||||||
|
|
||||||
sysinfo = info["system"]["get_sysinfo"]
|
sysinfo: Dict[str, Any] = info["system"]["get_sysinfo"]
|
||||||
type_ = sysinfo.get("type", sysinfo.get("mic_type"))
|
type_ = sysinfo.get("type", sysinfo.get("mic_type"))
|
||||||
if type_ is None:
|
if type_ is None:
|
||||||
raise SmartDeviceException("Unable to find the device type field!")
|
raise SmartDeviceException("Unable to find the device type field!")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user