Remove lovelace from mypy ignore list (#75167)

* Remove lovelace from mypy ignore list

* Raise error on failed config
This commit is contained in:
epenet 2022-07-14 13:08:50 +02:00 committed by GitHub
parent 28c082a080
commit c260413e2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 24 deletions

View File

@ -86,11 +86,15 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
config = await async_process_component_config(hass, conf, integration) config = await async_process_component_config(hass, conf, integration)
if config is None:
raise HomeAssistantError("Config validation failed")
resource_collection = await create_yaml_resource_col( resource_collection = await create_yaml_resource_col(
hass, config[DOMAIN].get(CONF_RESOURCES) hass, config[DOMAIN].get(CONF_RESOURCES)
) )
hass.data[DOMAIN]["resources"] = resource_collection hass.data[DOMAIN]["resources"] = resource_collection
default_config: dashboard.LovelaceConfig
if mode == MODE_YAML: if mode == MODE_YAML:
default_config = dashboard.LovelaceYAML(hass, None, None) default_config = dashboard.LovelaceYAML(hass, None, None)
resource_collection = await create_yaml_resource_col(hass, yaml_resources) resource_collection = await create_yaml_resource_col(hass, yaml_resources)
@ -179,8 +183,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
# Process YAML dashboards # Process YAML dashboards
for url_path, dashboard_conf in hass.data[DOMAIN]["yaml_dashboards"].items(): for url_path, dashboard_conf in hass.data[DOMAIN]["yaml_dashboards"].items():
# For now always mode=yaml # For now always mode=yaml
config = dashboard.LovelaceYAML(hass, url_path, dashboard_conf) lovelace_config = dashboard.LovelaceYAML(hass, url_path, dashboard_conf)
hass.data[DOMAIN]["dashboards"][url_path] = config hass.data[DOMAIN]["dashboards"][url_path] = lovelace_config
try: try:
_register_panel(hass, url_path, MODE_YAML, dashboard_conf, False) _register_panel(hass, url_path, MODE_YAML, dashboard_conf, False)

View File

@ -7,7 +7,7 @@ import uuid
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_RESOURCES, CONF_TYPE from homeassistant.const import CONF_ID, CONF_RESOURCES, CONF_TYPE
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import collection, storage from homeassistant.helpers import collection, storage
@ -94,7 +94,7 @@ class ResourceStorageCollection(collection.StorageCollection):
conf.pop(CONF_RESOURCES) conf.pop(CONF_RESOURCES)
for item in data: for item in data:
item[collection.CONF_ID] = uuid.uuid4().hex item[CONF_ID] = uuid.uuid4().hex
data = {"items": data} data = {"items": data}

View File

@ -45,8 +45,8 @@ def _handle_errors(func):
return send_with_error_handling return send_with_error_handling
@websocket_api.async_response
@websocket_api.websocket_command({"type": "lovelace/resources"}) @websocket_api.websocket_command({"type": "lovelace/resources"})
@websocket_api.async_response
async def websocket_lovelace_resources(hass, connection, msg): async def websocket_lovelace_resources(hass, connection, msg):
"""Send Lovelace UI resources over WebSocket configuration.""" """Send Lovelace UI resources over WebSocket configuration."""
resources = hass.data[DOMAIN]["resources"] resources = hass.data[DOMAIN]["resources"]
@ -58,7 +58,6 @@ async def websocket_lovelace_resources(hass, connection, msg):
connection.send_result(msg["id"], resources.async_items()) connection.send_result(msg["id"], resources.async_items())
@websocket_api.async_response
@websocket_api.websocket_command( @websocket_api.websocket_command(
{ {
"type": "lovelace/config", "type": "lovelace/config",
@ -66,6 +65,7 @@ async def websocket_lovelace_resources(hass, connection, msg):
vol.Optional(CONF_URL_PATH): vol.Any(None, cv.string), vol.Optional(CONF_URL_PATH): vol.Any(None, cv.string),
} }
) )
@websocket_api.async_response
@_handle_errors @_handle_errors
async def websocket_lovelace_config(hass, connection, msg, config): async def websocket_lovelace_config(hass, connection, msg, config):
"""Send Lovelace UI config over WebSocket configuration.""" """Send Lovelace UI config over WebSocket configuration."""
@ -73,7 +73,6 @@ async def websocket_lovelace_config(hass, connection, msg, config):
@websocket_api.require_admin @websocket_api.require_admin
@websocket_api.async_response
@websocket_api.websocket_command( @websocket_api.websocket_command(
{ {
"type": "lovelace/config/save", "type": "lovelace/config/save",
@ -81,6 +80,7 @@ async def websocket_lovelace_config(hass, connection, msg, config):
vol.Optional(CONF_URL_PATH): vol.Any(None, cv.string), vol.Optional(CONF_URL_PATH): vol.Any(None, cv.string),
} }
) )
@websocket_api.async_response
@_handle_errors @_handle_errors
async def websocket_lovelace_save_config(hass, connection, msg, config): async def websocket_lovelace_save_config(hass, connection, msg, config):
"""Save Lovelace UI configuration.""" """Save Lovelace UI configuration."""
@ -88,13 +88,13 @@ async def websocket_lovelace_save_config(hass, connection, msg, config):
@websocket_api.require_admin @websocket_api.require_admin
@websocket_api.async_response
@websocket_api.websocket_command( @websocket_api.websocket_command(
{ {
"type": "lovelace/config/delete", "type": "lovelace/config/delete",
vol.Optional(CONF_URL_PATH): vol.Any(None, cv.string), vol.Optional(CONF_URL_PATH): vol.Any(None, cv.string),
} }
) )
@websocket_api.async_response
@_handle_errors @_handle_errors
async def websocket_lovelace_delete_config(hass, connection, msg, config): async def websocket_lovelace_delete_config(hass, connection, msg, config):
"""Delete Lovelace UI configuration.""" """Delete Lovelace UI configuration."""

View File

@ -2668,18 +2668,6 @@ ignore_errors = true
[mypy-homeassistant.components.evohome.climate] [mypy-homeassistant.components.evohome.climate]
ignore_errors = true ignore_errors = true
[mypy-homeassistant.components.lovelace]
ignore_errors = true
[mypy-homeassistant.components.lovelace.dashboard]
ignore_errors = true
[mypy-homeassistant.components.lovelace.resources]
ignore_errors = true
[mypy-homeassistant.components.lovelace.websocket]
ignore_errors = true
[mypy-homeassistant.components.minecraft_server] [mypy-homeassistant.components.minecraft_server]
ignore_errors = true ignore_errors = true

View File

@ -20,10 +20,6 @@ IGNORED_MODULES: Final[list[str]] = [
"homeassistant.components.cloud.http_api", "homeassistant.components.cloud.http_api",
"homeassistant.components.evohome", "homeassistant.components.evohome",
"homeassistant.components.evohome.climate", "homeassistant.components.evohome.climate",
"homeassistant.components.lovelace",
"homeassistant.components.lovelace.dashboard",
"homeassistant.components.lovelace.resources",
"homeassistant.components.lovelace.websocket",
"homeassistant.components.minecraft_server", "homeassistant.components.minecraft_server",
"homeassistant.components.minecraft_server.helpers", "homeassistant.components.minecraft_server.helpers",
"homeassistant.components.minecraft_server.sensor", "homeassistant.components.minecraft_server.sensor",