Make Store a generic class (#74617)
This commit is contained in:
parent
d37ad20894
commit
16900dcef1
27 changed files with 106 additions and 97 deletions
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any, cast
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.singleton import singleton
|
||||
|
@ -38,8 +38,10 @@ class Network:
|
|||
|
||||
def __init__(self, hass: HomeAssistant) -> None:
|
||||
"""Initialize the Network class."""
|
||||
self._store = Store(hass, STORAGE_VERSION, STORAGE_KEY, atomic_writes=True)
|
||||
self._data: dict[str, Any] = {}
|
||||
self._store = Store[dict[str, list[str]]](
|
||||
hass, STORAGE_VERSION, STORAGE_KEY, atomic_writes=True
|
||||
)
|
||||
self._data: dict[str, list[str]] = {}
|
||||
self.adapters: list[Adapter] = []
|
||||
|
||||
@property
|
||||
|
@ -67,7 +69,7 @@ class Network:
|
|||
async def async_load(self) -> None:
|
||||
"""Load config."""
|
||||
if stored := await self._store.async_load():
|
||||
self._data = cast(dict, stored)
|
||||
self._data = stored
|
||||
|
||||
async def _async_save(self) -> None:
|
||||
"""Save preferences."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue