Guard type checking assertions in unifiprotect (#96721)
parent
1e9a5e48c3
commit
194d4e4f66
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from collections.abc import Callable, Sequence
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from pyunifiprotect.data import (
|
||||
NVR,
|
||||
|
@ -57,7 +57,8 @@ def _async_device_entities(
|
|||
else data.get_by_types({model_type}, ignore_unadopted=False)
|
||||
)
|
||||
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:
|
||||
for description in unadopted_descs:
|
||||
entities.append(
|
||||
|
@ -237,7 +238,8 @@ class ProtectDeviceEntity(Entity):
|
|||
@callback
|
||||
def _async_update_device_from_protect(self, device: ProtectModelWithId) -> None:
|
||||
"""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:
|
||||
self.device = device
|
||||
|
|
Loading…
Reference in New Issue