Make Store a generic class (#74617)

This commit is contained in:
epenet 2022-07-09 22:32:57 +02:00 committed by GitHub
parent d37ad20894
commit 16900dcef1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 106 additions and 97 deletions

View file

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