Enable basic type checking for analytics (#54928)

This commit is contained in:
Erik Montnemery 2021-08-21 11:46:28 +02:00 committed by GitHub
parent 7e5ff825dd
commit efd15344e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 8 deletions

View File

@ -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,

View File

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

View File

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

View File

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