mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Guard type checking assertions in unifiprotect (#96721)
This commit is contained in:
parent
1e9a5e48c3
commit
194d4e4f66
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from collections.abc import Callable, Sequence
|
from collections.abc import Callable, Sequence
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from pyunifiprotect.data import (
|
from pyunifiprotect.data import (
|
||||||
NVR,
|
NVR,
|
||||||
@ -57,7 +57,8 @@ def _async_device_entities(
|
|||||||
else data.get_by_types({model_type}, ignore_unadopted=False)
|
else data.get_by_types({model_type}, ignore_unadopted=False)
|
||||||
)
|
)
|
||||||
for device in devices:
|
for device in devices:
|
||||||
assert isinstance(device, (Camera, Light, Sensor, Viewer, Doorlock, Chime))
|
if TYPE_CHECKING:
|
||||||
|
assert isinstance(device, (Camera, Light, Sensor, Viewer, Doorlock, Chime))
|
||||||
if not device.is_adopted_by_us:
|
if not device.is_adopted_by_us:
|
||||||
for description in unadopted_descs:
|
for description in unadopted_descs:
|
||||||
entities.append(
|
entities.append(
|
||||||
@ -237,7 +238,8 @@ class ProtectDeviceEntity(Entity):
|
|||||||
@callback
|
@callback
|
||||||
def _async_update_device_from_protect(self, device: ProtectModelWithId) -> None:
|
def _async_update_device_from_protect(self, device: ProtectModelWithId) -> None:
|
||||||
"""Update Entity object from Protect device."""
|
"""Update Entity object from Protect device."""
|
||||||
assert isinstance(device, ProtectAdoptableDeviceModel)
|
if TYPE_CHECKING:
|
||||||
|
assert isinstance(device, ProtectAdoptableDeviceModel)
|
||||||
|
|
||||||
if last_update_success := self.data.last_update_success:
|
if last_update_success := self.data.last_update_success:
|
||||||
self.device = device
|
self.device = device
|
||||||
|
Loading…
x
Reference in New Issue
Block a user