mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 18:54:08 +00:00
Exclude __getattr__ for deprecated attributes from type checkers (#1294)
This commit is contained in:
@@ -154,7 +154,7 @@ class IotDimmer(IotPlug):
|
||||
"""
|
||||
if transition is not None:
|
||||
return await self.set_dimmer_transition(
|
||||
brightness=self.brightness, transition=transition
|
||||
brightness=self._brightness, transition=transition
|
||||
)
|
||||
|
||||
return await super().turn_on()
|
||||
|
@@ -3,13 +3,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from ..exceptions import KasaException
|
||||
from ..module import Module
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .iotdevice import IotDevice
|
||||
|
||||
|
||||
def _merge_dict(dest: dict, source: dict) -> dict:
|
||||
"""Update dict recursively."""
|
||||
@@ -27,6 +30,8 @@ merge = _merge_dict
|
||||
class IotModule(Module):
|
||||
"""Base class implemention for all IOT modules."""
|
||||
|
||||
_device: IotDevice
|
||||
|
||||
async def call(self, method: str, params: dict | None = None) -> dict:
|
||||
"""Call the given method with the given parameters."""
|
||||
return await self._device._query_helper(self._module, method, params)
|
||||
|
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
import logging
|
||||
from collections import defaultdict
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from ..device_type import DeviceType
|
||||
from ..deviceconfig import DeviceConfig
|
||||
@@ -145,6 +145,8 @@ class IotStrip(IotDevice):
|
||||
|
||||
if update_children:
|
||||
for plug in self.children:
|
||||
if TYPE_CHECKING:
|
||||
assert isinstance(plug, IotStripPlug)
|
||||
await plug._update()
|
||||
|
||||
if not self.features:
|
||||
|
@@ -207,6 +207,8 @@ class Light(IotModule, LightInterface):
|
||||
# iot protocol Dimmers and smart protocol devices do not support
|
||||
# brightness of 0 so 0 will turn off all devices for consistency
|
||||
if (bulb := self._get_bulb_device()) is None: # Dimmer
|
||||
if TYPE_CHECKING:
|
||||
assert isinstance(self._device, IotDimmer)
|
||||
if state.brightness == 0 or state.light_on is False:
|
||||
return await self._device.turn_off(transition=state.transition)
|
||||
elif state.brightness:
|
||||
|
Reference in New Issue
Block a user