Fix mypy issues in zha store (#74032)

This commit is contained in:
epenet 2022-06-28 08:52:20 +02:00 committed by GitHub
parent cc8170fcfe
commit 87b46a699a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 10 deletions

View file

@ -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()

View file

@ -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

View file

@ -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.