mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Fix mypy issues in zha store (#74032)
This commit is contained in:
parent
cc8170fcfe
commit
87b46a699a
@ -5,7 +5,7 @@ from collections import OrderedDict
|
||||
from collections.abc import MutableMapping
|
||||
import datetime
|
||||
import time
|
||||
from typing import TYPE_CHECKING, cast
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
||||
import attr
|
||||
|
||||
@ -45,10 +45,11 @@ class ZhaStorage:
|
||||
@callback
|
||||
def async_create_device(self, device: ZHADevice) -> ZhaDeviceEntry:
|
||||
"""Create a new ZhaDeviceEntry."""
|
||||
ieee_str: str = str(device.ieee)
|
||||
device_entry: ZhaDeviceEntry = ZhaDeviceEntry(
|
||||
name=device.name, ieee=str(device.ieee), last_seen=device.last_seen
|
||||
name=device.name, ieee=ieee_str, last_seen=device.last_seen
|
||||
)
|
||||
self.devices[device_entry.ieee] = device_entry
|
||||
self.devices[ieee_str] = device_entry
|
||||
self.async_schedule_save()
|
||||
return device_entry
|
||||
|
||||
@ -81,8 +82,8 @@ class ZhaStorage:
|
||||
ieee_str: str = str(device.ieee)
|
||||
old = self.devices[ieee_str]
|
||||
|
||||
if old is not None and device.last_seen is None:
|
||||
return
|
||||
if device.last_seen is None:
|
||||
return old
|
||||
|
||||
changes = {}
|
||||
changes["last_seen"] = device.last_seen
|
||||
@ -93,7 +94,7 @@ class ZhaStorage:
|
||||
|
||||
async def async_load(self) -> None:
|
||||
"""Load the registry of zha device entries."""
|
||||
data = await self._store.async_load()
|
||||
data = cast(dict[str, Any], await self._store.async_load())
|
||||
|
||||
devices: OrderedDict[str, ZhaDeviceEntry] = OrderedDict()
|
||||
|
||||
|
3
mypy.ini
3
mypy.ini
@ -3001,6 +3001,3 @@ ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.registries]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.store]
|
||||
ignore_errors = true
|
||||
|
@ -146,7 +146,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
||||
"homeassistant.components.xiaomi_miio.switch",
|
||||
"homeassistant.components.zha.core.discovery",
|
||||
"homeassistant.components.zha.core.registries",
|
||||
"homeassistant.components.zha.core.store",
|
||||
]
|
||||
|
||||
# Component modules which should set no_implicit_reexport = true.
|
||||
|
Loading…
x
Reference in New Issue
Block a user