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