mirror of https://github.com/home-assistant/core
Mark stt entity component as strictly typed (#106723)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
This commit is contained in:
parent
e7b0bf2453
commit
2d0325a471
|
@ -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.*
|
||||
|
|
|
@ -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
|
||||
]
|
||||
|
||||
|
||||
|
|
10
mypy.ini
10
mypy.ini
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue