mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
Avoid call to hass.helpers.store
in FloorRegistry (#111554)
* Avoid call to `hass.helpers.store` in FloorRegistry * Change type annotation
This commit is contained in:
parent
cf849664ba
commit
c8b7f098e5
@ -5,11 +5,12 @@ from collections import UserDict
|
|||||||
from collections.abc import Iterable, ValuesView
|
from collections.abc import Iterable, ValuesView
|
||||||
import dataclasses
|
import dataclasses
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Literal, TypedDict, cast
|
from typing import TYPE_CHECKING, Literal, TypedDict, cast
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
|
from .storage import Store
|
||||||
from .typing import UNDEFINED, EventType, UndefinedType
|
from .typing import UNDEFINED, EventType, UndefinedType
|
||||||
|
|
||||||
DATA_REGISTRY = "floor_registry"
|
DATA_REGISTRY = "floor_registry"
|
||||||
@ -96,7 +97,10 @@ class FloorRegistry:
|
|||||||
def __init__(self, hass: HomeAssistant) -> None:
|
def __init__(self, hass: HomeAssistant) -> None:
|
||||||
"""Initialize the floor registry."""
|
"""Initialize the floor registry."""
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self._store = hass.helpers.storage.Store(
|
self._store: Store[
|
||||||
|
dict[str, list[dict[str, str | int | list[str] | None]]]
|
||||||
|
] = Store(
|
||||||
|
hass,
|
||||||
STORAGE_VERSION_MAJOR,
|
STORAGE_VERSION_MAJOR,
|
||||||
STORAGE_KEY,
|
STORAGE_KEY,
|
||||||
atomic_writes=True,
|
atomic_writes=True,
|
||||||
@ -229,6 +233,13 @@ class FloorRegistry:
|
|||||||
|
|
||||||
if data is not None:
|
if data is not None:
|
||||||
for floor in data["floors"]:
|
for floor in data["floors"]:
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
assert isinstance(floor["aliases"], list)
|
||||||
|
assert isinstance(floor["icon"], str)
|
||||||
|
assert isinstance(floor["level"], int)
|
||||||
|
assert isinstance(floor["name"], str)
|
||||||
|
assert isinstance(floor["floor_id"], str)
|
||||||
|
|
||||||
normalized_name = _normalize_floor_name(floor["name"])
|
normalized_name = _normalize_floor_name(floor["name"])
|
||||||
floors[floor["floor_id"]] = FloorEntry(
|
floors[floor["floor_id"]] = FloorEntry(
|
||||||
aliases=set(floor["aliases"]),
|
aliases=set(floor["aliases"]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user