mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Enable strict typing of deconz_device (#70341)
* Enable strict typing of deconz_device completing strict typing of deconz integration
This commit is contained in:
parent
74b50a8009
commit
69f4aeaf42
@ -63,27 +63,7 @@ homeassistant.components.canary.*
|
|||||||
homeassistant.components.cover.*
|
homeassistant.components.cover.*
|
||||||
homeassistant.components.crownstone.*
|
homeassistant.components.crownstone.*
|
||||||
homeassistant.components.cpuspeed.*
|
homeassistant.components.cpuspeed.*
|
||||||
homeassistant.components.deconz
|
homeassistant.components.deconz.*
|
||||||
homeassistant.components.deconz.alarm_control_panel
|
|
||||||
homeassistant.components.deconz.binary_sensor
|
|
||||||
homeassistant.components.deconz.button
|
|
||||||
homeassistant.components.deconz.climate
|
|
||||||
homeassistant.components.deconz.config_flow
|
|
||||||
homeassistant.components.deconz.cover
|
|
||||||
homeassistant.components.deconz.deconz_event
|
|
||||||
homeassistant.components.deconz.device_trigger
|
|
||||||
homeassistant.components.deconz.diagnostics
|
|
||||||
homeassistant.components.deconz.fan
|
|
||||||
homeassistant.components.deconz.gateway
|
|
||||||
homeassistant.components.deconz.light
|
|
||||||
homeassistant.components.deconz.lock
|
|
||||||
homeassistant.components.deconz.logbook
|
|
||||||
homeassistant.components.deconz.number
|
|
||||||
homeassistant.components.deconz.scene
|
|
||||||
homeassistant.components.deconz.sensor
|
|
||||||
homeassistant.components.deconz.services
|
|
||||||
homeassistant.components.deconz.siren
|
|
||||||
homeassistant.components.deconz.switch
|
|
||||||
homeassistant.components.device_automation.*
|
homeassistant.components.device_automation.*
|
||||||
homeassistant.components.device_tracker.*
|
homeassistant.components.device_tracker.*
|
||||||
homeassistant.components.devolo_home_control.*
|
homeassistant.components.devolo_home_control.*
|
||||||
|
@ -20,7 +20,7 @@ class DeconzBase:
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
device: DeconzGroup | DeconzLight | DeconzSensor,
|
device: DeconzGroup | DeconzLight | DeconzSensor | PydeconzScene,
|
||||||
gateway: DeconzGateway,
|
gateway: DeconzGateway,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up device and add update callback to get data from websocket."""
|
"""Set up device and add update callback to get data from websocket."""
|
||||||
@ -30,19 +30,21 @@ class DeconzBase:
|
|||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return a unique identifier for this device."""
|
"""Return a unique identifier for this device."""
|
||||||
return self._device.unique_id
|
assert not isinstance(self._device, PydeconzScene)
|
||||||
|
return self._device.unique_id # type: ignore[no-any-return]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def serial(self) -> str | None:
|
def serial(self) -> str | None:
|
||||||
"""Return a serial number for this device."""
|
"""Return a serial number for this device."""
|
||||||
|
assert not isinstance(self._device, PydeconzScene)
|
||||||
if not self._device.unique_id or self._device.unique_id.count(":") != 7:
|
if not self._device.unique_id or self._device.unique_id.count(":") != 7:
|
||||||
return None
|
return None
|
||||||
|
return self._device.unique_id.split("-", 1)[0] # type: ignore[no-any-return]
|
||||||
return self._device.unique_id.split("-", 1)[0]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo | None:
|
def device_info(self) -> DeviceInfo | None:
|
||||||
"""Return a device description for device registry."""
|
"""Return a device description for device registry."""
|
||||||
|
assert not isinstance(self._device, PydeconzScene)
|
||||||
if self.serial is None:
|
if self.serial is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -66,7 +68,7 @@ class DeconzDevice(DeconzBase, Entity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
device: DeconzGroup | DeconzLight | DeconzSensor,
|
device: DeconzGroup | DeconzLight | DeconzSensor | PydeconzScene,
|
||||||
gateway: DeconzGateway,
|
gateway: DeconzGateway,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up device and add update callback to get data from websocket."""
|
"""Set up device and add update callback to get data from websocket."""
|
||||||
@ -109,6 +111,8 @@ class DeconzDevice(DeconzBase, Entity):
|
|||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return True if device is available."""
|
"""Return True if device is available."""
|
||||||
|
if isinstance(self._device, PydeconzScene):
|
||||||
|
return self.gateway.available
|
||||||
return self.gateway.available and self._device.reachable
|
return self.gateway.available and self._device.reachable
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +121,11 @@ class DeconzSceneMixin(DeconzDevice):
|
|||||||
|
|
||||||
_device: PydeconzScene
|
_device: PydeconzScene
|
||||||
|
|
||||||
def __init__(self, device: PydeconzScene, gateway: DeconzGateway) -> None:
|
def __init__(
|
||||||
|
self,
|
||||||
|
device: PydeconzScene,
|
||||||
|
gateway: DeconzGateway,
|
||||||
|
) -> None:
|
||||||
"""Set up a scene."""
|
"""Set up a scene."""
|
||||||
super().__init__(device, gateway)
|
super().__init__(device, gateway)
|
||||||
|
|
||||||
@ -132,11 +140,6 @@ class DeconzSceneMixin(DeconzDevice):
|
|||||||
"""Describe a unique identifier for group this scene belongs to."""
|
"""Describe a unique identifier for group this scene belongs to."""
|
||||||
return f"{self.gateway.bridgeid}-{self._device.group_deconz_id}"
|
return f"{self.gateway.bridgeid}-{self._device.group_deconz_id}"
|
||||||
|
|
||||||
@property
|
|
||||||
def available(self) -> bool:
|
|
||||||
"""Return True if scene is available."""
|
|
||||||
return self.gateway.available
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return a unique identifier for this scene."""
|
"""Return a unique identifier for this scene."""
|
||||||
|
222
mypy.ini
222
mypy.ini
@ -495,227 +495,7 @@ no_implicit_optional = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz]
|
[mypy-homeassistant.components.deconz.*]
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.alarm_control_panel]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.binary_sensor]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.button]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.climate]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.config_flow]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.cover]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.deconz_event]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.device_trigger]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.diagnostics]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.fan]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.gateway]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.light]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.lock]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.logbook]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.number]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.scene]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.sensor]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.services]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.siren]
|
|
||||||
check_untyped_defs = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_optional = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unreachable = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.deconz.switch]
|
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
disallow_subclassing_any = true
|
disallow_subclassing_any = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user