Avoid some implicit generic Anys (#54577)
This commit is contained in:
parent
b72ed68d61
commit
848c0be58a
14 changed files with 69 additions and 29 deletions
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
from collections.abc import Iterable
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant import config as conf_util
|
||||
from homeassistant.const import SERVICE_RELOAD
|
||||
|
@ -15,11 +16,13 @@ from homeassistant.helpers.typing import ConfigType
|
|||
from homeassistant.loader import async_get_integration
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
# mypy: disallow-any-generics
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_reload_integration_platforms(
|
||||
hass: HomeAssistant, integration_name: str, integration_platforms: Iterable
|
||||
hass: HomeAssistant, integration_name: str, integration_platforms: Iterable[str]
|
||||
) -> None:
|
||||
"""Reload an integration's platforms.
|
||||
|
||||
|
@ -62,7 +65,7 @@ async def _resetup_platform(
|
|||
if not conf:
|
||||
return
|
||||
|
||||
root_config: dict = {integration_platform: []}
|
||||
root_config: dict[str, Any] = {integration_platform: []}
|
||||
# Extract only the config for template, ignore the rest.
|
||||
for p_type, p_config in config_per_platform(conf, integration_platform):
|
||||
if p_type != integration_name:
|
||||
|
@ -102,7 +105,7 @@ async def _async_setup_platform(
|
|||
hass: HomeAssistant,
|
||||
integration_name: str,
|
||||
integration_platform: str,
|
||||
platform_configs: list[dict],
|
||||
platform_configs: list[dict[str, Any]],
|
||||
) -> None:
|
||||
"""Platform for the first time when new configuration is added."""
|
||||
if integration_platform not in hass.data:
|
||||
|
@ -120,7 +123,7 @@ async def _async_setup_platform(
|
|||
|
||||
|
||||
async def _async_reconfig_platform(
|
||||
platform: EntityPlatform, platform_configs: list[dict]
|
||||
platform: EntityPlatform, platform_configs: list[dict[str, Any]]
|
||||
) -> None:
|
||||
"""Reconfigure an already loaded platform."""
|
||||
await platform.async_reset()
|
||||
|
@ -155,7 +158,7 @@ def async_get_platform_without_config_entry(
|
|||
|
||||
|
||||
async def async_setup_reload_service(
|
||||
hass: HomeAssistant, domain: str, platforms: Iterable
|
||||
hass: HomeAssistant, domain: str, platforms: Iterable[str]
|
||||
) -> None:
|
||||
"""Create the reload service for the domain."""
|
||||
if hass.services.has_service(domain, SERVICE_RELOAD):
|
||||
|
@ -171,7 +174,9 @@ async def async_setup_reload_service(
|
|||
)
|
||||
|
||||
|
||||
def setup_reload_service(hass: HomeAssistant, domain: str, platforms: Iterable) -> None:
|
||||
def setup_reload_service(
|
||||
hass: HomeAssistant, domain: str, platforms: Iterable[str]
|
||||
) -> None:
|
||||
"""Sync version of async_setup_reload_service."""
|
||||
asyncio.run_coroutine_threadsafe(
|
||||
async_setup_reload_service(hass, domain, platforms),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue