Skip to content

Commit

Permalink
Fix mypy issues in zha store (#74032)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Jun 28, 2022
1 parent cc8170f commit 87b46a6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
13 changes: 7 additions & 6 deletions homeassistant/components/zha/core/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections.abc import MutableMapping
import datetime
import time
from typing import TYPE_CHECKING, cast
from typing import TYPE_CHECKING, Any, cast

import attr

Expand Down Expand Up @@ -45,10 +45,11 @@ def __init__(self, hass: HomeAssistant) -> None:
@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

Expand Down Expand Up @@ -81,8 +82,8 @@ def async_update_device(self, device: ZHADevice) -> ZhaDeviceEntry:
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
Expand All @@ -93,7 +94,7 @@ def async_update_device(self, device: ZHADevice) -> ZhaDeviceEntry:

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

Expand Down
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion script/hassfest/mypy_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
"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.
Expand Down

0 comments on commit 87b46a6

Please sign in to comment.