Enable strict typing for config (#108023)

This commit is contained in:
Marc Mueller 2024-01-18 09:20:19 +01:00 committed by GitHub
parent 26cc6a5bb4
commit afcb7a26cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 178 additions and 76 deletions

View file

@ -1,4 +1,8 @@
"""Provide configuration end points for scripts."""
from __future__ import annotations
from typing import Any
from homeassistant.components.script import DOMAIN
from homeassistant.components.script.config import (
SCRIPT_ENTITY_SCHEMA,
@ -6,15 +10,16 @@ from homeassistant.components.script.config import (
)
from homeassistant.config import SCRIPT_CONFIG_PATH
from homeassistant.const import SERVICE_RELOAD
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_registry as er
from . import ACTION_DELETE, EditKeyBasedConfigView
async def async_setup(hass):
async def async_setup(hass: HomeAssistant) -> bool:
"""Set up the script config API."""
async def hook(action, config_key):
async def hook(action: str, config_key: str) -> None:
"""post_write_hook for Config View that reloads scripts."""
if action != ACTION_DELETE:
await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
@ -46,6 +51,12 @@ async def async_setup(hass):
class EditScriptConfigView(EditKeyBasedConfigView):
"""Edit script config."""
def _write_value(self, hass, data, config_key, new_value):
def _write_value(
self,
hass: HomeAssistant,
data: dict[str, dict[str, Any]],
config_key: str,
new_value: dict[str, Any],
) -> None:
"""Set value."""
data[config_key] = new_value