Mark stt entity component as strictly typed (#106723)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
This commit is contained in:
Franck Nijhof 2024-01-02 17:07:47 +01:00 committed by GitHub
parent e7b0bf2453
commit 2d0325a471
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View File

@ -351,6 +351,7 @@ homeassistant.components.steamist.*
homeassistant.components.stookalert.*
homeassistant.components.stream.*
homeassistant.components.streamlabswater.*
homeassistant.components.stt.*
homeassistant.components.suez_water.*
homeassistant.components.sun.*
homeassistant.components.surepetcare.*

View File

@ -9,7 +9,7 @@ from typing import Any
from homeassistant.config import config_per_platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import discovery
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.setup import async_prepare_setup_platform
from .const import (
@ -37,11 +37,12 @@ def async_get_provider(
hass: HomeAssistant, domain: str | None = None
) -> Provider | None:
"""Return provider."""
providers: dict[str, Provider] = hass.data[DATA_PROVIDERS]
if domain:
return hass.data[DATA_PROVIDERS].get(domain)
return providers.get(domain)
provider = async_default_provider(hass)
return hass.data[DATA_PROVIDERS][provider] if provider is not None else None
return providers[provider] if provider is not None else None
@callback
@ -51,7 +52,11 @@ def async_setup_legacy(
"""Set up legacy speech-to-text providers."""
providers = hass.data[DATA_PROVIDERS] = {}
async def async_setup_platform(p_type, p_config=None, discovery_info=None):
async def async_setup_platform(
p_type: str,
p_config: ConfigType | None = None,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up an STT platform."""
if p_config is None:
p_config = {}
@ -73,7 +78,9 @@ def async_setup_legacy(
return
# Add discovery support
async def async_platform_discovered(platform, info):
async def async_platform_discovered(
platform: str, info: DiscoveryInfoType | None
) -> None:
"""Handle for discovered platform."""
await async_setup_platform(platform, discovery_info=info)
@ -82,6 +89,7 @@ def async_setup_legacy(
return [
async_setup_platform(p_type, p_config)
for p_type, p_config in config_per_platform(config, DOMAIN)
if p_type
]

View File

@ -3272,6 +3272,16 @@ disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.stt.*]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.suez_water.*]
check_untyped_defs = true
disallow_incomplete_defs = true