mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Enable basic type checking for analytics (#54928)
This commit is contained in:
parent
7e5ff825dd
commit
efd15344e9
@ -36,8 +36,8 @@ async def async_setup(hass: HomeAssistant, _: ConfigType) -> bool:
|
||||
|
||||
|
||||
@websocket_api.require_admin
|
||||
@websocket_api.async_response
|
||||
@websocket_api.websocket_command({vol.Required("type"): "analytics"})
|
||||
@websocket_api.async_response
|
||||
async def websocket_analytics(
|
||||
hass: HomeAssistant,
|
||||
connection: websocket_api.connection.ActiveConnection,
|
||||
@ -52,13 +52,13 @@ async def websocket_analytics(
|
||||
|
||||
|
||||
@websocket_api.require_admin
|
||||
@websocket_api.async_response
|
||||
@websocket_api.websocket_command(
|
||||
{
|
||||
vol.Required("type"): "analytics/preferences",
|
||||
vol.Required("preferences", default={}): PREFERENCE_SCHEMA,
|
||||
}
|
||||
)
|
||||
@websocket_api.async_response
|
||||
async def websocket_analytics_preferences(
|
||||
hass: HomeAssistant,
|
||||
connection: websocket_api.connection.ActiveConnection,
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Analytics helper class for the analytics integration."""
|
||||
import asyncio
|
||||
from typing import cast
|
||||
import uuid
|
||||
|
||||
import aiohttp
|
||||
@ -64,7 +65,11 @@ class Analytics:
|
||||
"""Initialize the Analytics class."""
|
||||
self.hass: HomeAssistant = hass
|
||||
self.session = async_get_clientsession(hass)
|
||||
self._data = {ATTR_PREFERENCES: {}, ATTR_ONBOARDED: False, ATTR_UUID: None}
|
||||
self._data: dict = {
|
||||
ATTR_PREFERENCES: {},
|
||||
ATTR_ONBOARDED: False,
|
||||
ATTR_UUID: None,
|
||||
}
|
||||
self._store: Store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
|
||||
|
||||
@property
|
||||
@ -103,7 +108,7 @@ class Analytics:
|
||||
|
||||
async def load(self) -> None:
|
||||
"""Load preferences."""
|
||||
stored = await self._store.async_load()
|
||||
stored = cast(dict, await self._store.async_load())
|
||||
if stored:
|
||||
self._data = stored
|
||||
|
||||
|
3
mypy.ini
3
mypy.ini
@ -1268,9 +1268,6 @@ warn_unreachable = false
|
||||
[mypy-homeassistant.components.almond.*]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.analytics.*]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.atag.*]
|
||||
ignore_errors = true
|
||||
|
||||
|
@ -15,7 +15,6 @@ from .model import Config, Integration
|
||||
# Do your best to not add anything new here.
|
||||
IGNORED_MODULES: Final[list[str]] = [
|
||||
"homeassistant.components.almond.*",
|
||||
"homeassistant.components.analytics.*",
|
||||
"homeassistant.components.atag.*",
|
||||
"homeassistant.components.awair.*",
|
||||
"homeassistant.components.azure_event_hub.*",
|
||||
|
Loading…
x
Reference in New Issue
Block a user