mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-04-27 09:06:24 +00:00
fix mympy's error "Decorated property not supported" (mypy bug)
See https://github.com/python/mypy/issues/1362
This commit is contained in:
parent
122cd4c19f
commit
ad209de268
@ -94,7 +94,7 @@ class SmartBulb(SmartDevice):
|
|||||||
self._device_type = DeviceType.Bulb
|
self._device_type = DeviceType.Bulb
|
||||||
self._light_state = None
|
self._light_state = None
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def is_color(self) -> bool:
|
def is_color(self) -> bool:
|
||||||
"""Whether the bulb supports color changes.
|
"""Whether the bulb supports color changes.
|
||||||
@ -105,7 +105,7 @@ class SmartBulb(SmartDevice):
|
|||||||
sys_info = self.sys_info
|
sys_info = self.sys_info
|
||||||
return bool(sys_info["is_color"])
|
return bool(sys_info["is_color"])
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def is_dimmable(self) -> bool:
|
def is_dimmable(self) -> bool:
|
||||||
"""Whether the bulb supports brightness changes.
|
"""Whether the bulb supports brightness changes.
|
||||||
@ -116,7 +116,7 @@ class SmartBulb(SmartDevice):
|
|||||||
sys_info = self.sys_info
|
sys_info = self.sys_info
|
||||||
return bool(sys_info["is_dimmable"])
|
return bool(sys_info["is_dimmable"])
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def is_variable_color_temp(self) -> bool:
|
def is_variable_color_temp(self) -> bool:
|
||||||
"""Whether the bulb supports color temperature changes.
|
"""Whether the bulb supports color temperature changes.
|
||||||
@ -128,7 +128,7 @@ class SmartBulb(SmartDevice):
|
|||||||
sys_info = self.sys_info
|
sys_info = self.sys_info
|
||||||
return bool(sys_info["is_variable_color_temp"])
|
return bool(sys_info["is_variable_color_temp"])
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def valid_temperature_range(self) -> Tuple[int, int]:
|
def valid_temperature_range(self) -> Tuple[int, int]:
|
||||||
"""Return the device-specific white temperature range (in Kelvin).
|
"""Return the device-specific white temperature range (in Kelvin).
|
||||||
@ -149,7 +149,7 @@ class SmartBulb(SmartDevice):
|
|||||||
self._sys_info = await self.get_sys_info()
|
self._sys_info = await self.get_sys_info()
|
||||||
self._light_state = await self.get_light_state()
|
self._light_state = await self.get_light_state()
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def light_state(self) -> Optional[Dict[str, Dict]]:
|
def light_state(self) -> Optional[Dict[str, Dict]]:
|
||||||
"""Query the light state."""
|
"""Query the light state."""
|
||||||
@ -167,7 +167,7 @@ class SmartBulb(SmartDevice):
|
|||||||
await self.update()
|
await self.update()
|
||||||
return light_state
|
return light_state
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def hsv(self) -> Tuple[int, int, int]:
|
def hsv(self) -> Tuple[int, int, int]:
|
||||||
"""Return the current HSV state of the bulb.
|
"""Return the current HSV state of the bulb.
|
||||||
@ -228,7 +228,7 @@ class SmartBulb(SmartDevice):
|
|||||||
}
|
}
|
||||||
await self.set_light_state(light_state)
|
await self.set_light_state(light_state)
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def color_temp(self) -> int:
|
def color_temp(self) -> int:
|
||||||
"""Return color temperature of the device.
|
"""Return color temperature of the device.
|
||||||
@ -264,7 +264,7 @@ class SmartBulb(SmartDevice):
|
|||||||
light_state = {"color_temp": temp}
|
light_state = {"color_temp": temp}
|
||||||
await self.set_light_state(light_state)
|
await self.set_light_state(light_state)
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def brightness(self) -> int:
|
def brightness(self) -> int:
|
||||||
"""Return the current brightness.
|
"""Return the current brightness.
|
||||||
@ -295,7 +295,7 @@ class SmartBulb(SmartDevice):
|
|||||||
light_state = {"brightness": brightness}
|
light_state = {"brightness": brightness}
|
||||||
await self.set_light_state(light_state)
|
await self.set_light_state(light_state)
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def state_information(self) -> Dict[str, Any]:
|
def state_information(self) -> Dict[str, Any]:
|
||||||
"""Return bulb-specific state information.
|
"""Return bulb-specific state information.
|
||||||
@ -315,7 +315,7 @@ class SmartBulb(SmartDevice):
|
|||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return whether the device is on."""
|
"""Return whether the device is on."""
|
||||||
@ -330,7 +330,7 @@ class SmartBulb(SmartDevice):
|
|||||||
"""Turn the bulb on."""
|
"""Turn the bulb on."""
|
||||||
await self.set_light_state({"on_off": 1})
|
await self.set_light_state({"on_off": 1})
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def has_emeter(self) -> bool:
|
def has_emeter(self) -> bool:
|
||||||
"""Return that the bulb has an emeter."""
|
"""Return that the bulb has an emeter."""
|
||||||
|
@ -244,7 +244,7 @@ class SmartDevice:
|
|||||||
"""
|
"""
|
||||||
self._sys_info = await self.get_sys_info()
|
self._sys_info = await self.get_sys_info()
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def sys_info(self) -> Dict[str, Any]:
|
def sys_info(self) -> Dict[str, Any]:
|
||||||
"""Retrieve system information.
|
"""Retrieve system information.
|
||||||
@ -253,9 +253,10 @@ class SmartDevice:
|
|||||||
:rtype dict
|
:rtype dict
|
||||||
:raises SmartDeviceException: on error
|
:raises SmartDeviceException: on error
|
||||||
"""
|
"""
|
||||||
|
assert self._sys_info is not None
|
||||||
return self._sys_info
|
return self._sys_info
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def model(self) -> str:
|
def model(self) -> str:
|
||||||
"""Return device model.
|
"""Return device model.
|
||||||
@ -267,7 +268,7 @@ class SmartDevice:
|
|||||||
sys_info = self.sys_info
|
sys_info = self.sys_info
|
||||||
return str(sys_info["model"])
|
return str(sys_info["model"])
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def alias(self) -> str:
|
def alias(self) -> str:
|
||||||
"""Return device name (alias).
|
"""Return device name (alias).
|
||||||
@ -375,7 +376,7 @@ class SmartDevice:
|
|||||||
"""
|
"""
|
||||||
return await self._query_helper("time", "get_timezone")
|
return await self._query_helper("time", "get_timezone")
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def hw_info(self) -> Dict:
|
def hw_info(self) -> Dict:
|
||||||
"""Return hardware information.
|
"""Return hardware information.
|
||||||
@ -398,7 +399,7 @@ class SmartDevice:
|
|||||||
sys_info = self.sys_info
|
sys_info = self.sys_info
|
||||||
return {key: sys_info[key] for key in keys if key in sys_info}
|
return {key: sys_info[key] for key in keys if key in sys_info}
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def location(self) -> Dict:
|
def location(self) -> Dict:
|
||||||
"""Return geographical location.
|
"""Return geographical location.
|
||||||
@ -420,7 +421,7 @@ class SmartDevice:
|
|||||||
|
|
||||||
return loc
|
return loc
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def rssi(self) -> Optional[int]:
|
def rssi(self) -> Optional[int]:
|
||||||
"""Return WiFi signal strenth (rssi).
|
"""Return WiFi signal strenth (rssi).
|
||||||
@ -433,7 +434,7 @@ class SmartDevice:
|
|||||||
return int(sys_info["rssi"])
|
return int(sys_info["rssi"])
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def mac(self) -> str:
|
def mac(self) -> str:
|
||||||
"""Return mac address.
|
"""Return mac address.
|
||||||
@ -579,7 +580,7 @@ class SmartDevice:
|
|||||||
"""Turn off the device."""
|
"""Turn off the device."""
|
||||||
raise NotImplementedError("Device subclass needs to implement this.")
|
raise NotImplementedError("Device subclass needs to implement this.")
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def is_off(self) -> bool:
|
def is_off(self) -> bool:
|
||||||
"""Return True if device is off.
|
"""Return True if device is off.
|
||||||
@ -593,7 +594,7 @@ class SmartDevice:
|
|||||||
"""Turn device on."""
|
"""Turn device on."""
|
||||||
raise NotImplementedError("Device subclass needs to implement this.")
|
raise NotImplementedError("Device subclass needs to implement this.")
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return if the device is on.
|
"""Return if the device is on.
|
||||||
@ -604,7 +605,7 @@ class SmartDevice:
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError("Device subclass needs to implement this.")
|
raise NotImplementedError("Device subclass needs to implement this.")
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def state_information(self) -> Dict[str, Any]:
|
def state_information(self) -> Dict[str, Any]:
|
||||||
"""Return device-type specific, end-user friendly state information.
|
"""Return device-type specific, end-user friendly state information.
|
||||||
|
@ -51,7 +51,7 @@ class SmartPlug(SmartDevice):
|
|||||||
self.emeter_type = "emeter"
|
self.emeter_type = "emeter"
|
||||||
self._device_type = DeviceType.Plug
|
self._device_type = DeviceType.Plug
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def brightness(self) -> int:
|
def brightness(self) -> int:
|
||||||
"""Return current brightness on dimmers.
|
"""Return current brightness on dimmers.
|
||||||
@ -92,7 +92,7 @@ class SmartPlug(SmartDevice):
|
|||||||
else:
|
else:
|
||||||
raise ValueError("Brightness value %s is not valid." % value)
|
raise ValueError("Brightness value %s is not valid." % value)
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def is_dimmable(self):
|
def is_dimmable(self):
|
||||||
"""Whether the switch supports brightness changes.
|
"""Whether the switch supports brightness changes.
|
||||||
@ -103,7 +103,7 @@ class SmartPlug(SmartDevice):
|
|||||||
sys_info = self.sys_info
|
sys_info = self.sys_info
|
||||||
return "brightness" in sys_info
|
return "brightness" in sys_info
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def has_emeter(self):
|
def has_emeter(self):
|
||||||
"""Return whether device has an energy meter.
|
"""Return whether device has an energy meter.
|
||||||
@ -115,7 +115,7 @@ class SmartPlug(SmartDevice):
|
|||||||
features = sys_info["feature"].split(":")
|
features = sys_info["feature"].split(":")
|
||||||
return "ENE" in features
|
return "ENE" in features
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return whether device is on.
|
"""Return whether device is on.
|
||||||
@ -141,7 +141,7 @@ class SmartPlug(SmartDevice):
|
|||||||
await self._query_helper("system", "set_relay_state", {"state": 0})
|
await self._query_helper("system", "set_relay_state", {"state": 0})
|
||||||
await self.update()
|
await self.update()
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def led(self) -> bool:
|
def led(self) -> bool:
|
||||||
"""Return the state of the led.
|
"""Return the state of the led.
|
||||||
@ -161,7 +161,7 @@ class SmartPlug(SmartDevice):
|
|||||||
await self._query_helper("system", "set_led_off", {"off": int(not state)})
|
await self._query_helper("system", "set_led_off", {"off": int(not state)})
|
||||||
await self.update()
|
await self.update()
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def on_since(self) -> datetime.datetime:
|
def on_since(self) -> datetime.datetime:
|
||||||
"""Return pretty-printed on-time.
|
"""Return pretty-printed on-time.
|
||||||
@ -180,7 +180,7 @@ class SmartPlug(SmartDevice):
|
|||||||
|
|
||||||
return datetime.datetime.now() - datetime.timedelta(seconds=on_time)
|
return datetime.datetime.now() - datetime.timedelta(seconds=on_time)
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def state_information(self) -> Dict[str, Any]:
|
def state_information(self) -> Dict[str, Any]:
|
||||||
"""Return switch-specific state information.
|
"""Return switch-specific state information.
|
||||||
|
@ -66,7 +66,7 @@ class SmartStrip(SmartPlug):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return if any of the outlets are on."""
|
"""Return if any of the outlets are on."""
|
||||||
@ -101,13 +101,13 @@ class SmartStrip(SmartPlug):
|
|||||||
await self._query_helper("system", "set_relay_state", {"state": 0})
|
await self._query_helper("system", "set_relay_state", {"state": 0})
|
||||||
await self.update()
|
await self.update()
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def on_since(self) -> datetime.datetime:
|
def on_since(self) -> datetime.datetime:
|
||||||
"""Return the maximum on-time of all outlets."""
|
"""Return the maximum on-time of all outlets."""
|
||||||
return max(plug.on_since for plug in self.plugs)
|
return max(plug.on_since for plug in self.plugs)
|
||||||
|
|
||||||
@property
|
@property # type: ignore
|
||||||
@requires_update
|
@requires_update
|
||||||
def state_information(self) -> Dict[str, Any]:
|
def state_information(self) -> Dict[str, Any]:
|
||||||
"""Return strip-specific state information.
|
"""Return strip-specific state information.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user