Enable strict typing for google_assistant_sdk (#107306)

This commit is contained in:
Marc Mueller 2024-01-08 09:47:17 +01:00 committed by GitHub
parent fde7a6e9ef
commit f5d5e1dcbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 4 deletions

View File

@ -183,6 +183,7 @@ homeassistant.components.gios.*
homeassistant.components.glances.*
homeassistant.components.goalzero.*
homeassistant.components.google.*
homeassistant.components.google_assistant_sdk.*
homeassistant.components.google_sheets.*
homeassistant.components.gpsd.*
homeassistant.components.greeneye_monitor.*

View File

@ -104,7 +104,7 @@ async def async_send_text_commands(
return command_response_list
def default_language_code(hass: HomeAssistant):
def default_language_code(hass: HomeAssistant) -> str:
"""Get default language code based on Home Assistant config."""
language_code = f"{hass.config.language}-{hass.config.country}"
if language_code in SUPPORTED_LANGUAGE_CODES:

View File

@ -24,13 +24,13 @@ LANG_TO_BROADCAST_COMMAND = {
}
def broadcast_commands(language_code: str):
def broadcast_commands(language_code: str) -> tuple[str, str]:
"""Get the commands for broadcasting a message for the given language code.
Return type is a tuple where [0] is for broadcasting to your entire home,
while [1] is for broadcasting to a specific target.
"""
return LANG_TO_BROADCAST_COMMAND.get(language_code.split("-", maxsplit=1)[0])
return LANG_TO_BROADCAST_COMMAND[language_code.split("-", maxsplit=1)[0]]
async def async_get_service(
@ -60,7 +60,7 @@ class BroadcastNotificationService(BaseNotificationService):
CONF_LANGUAGE_CODE, default_language_code(self.hass)
)
commands = []
commands: list[str] = []
targets = kwargs.get(ATTR_TARGET)
if not targets:
commands.append(broadcast_commands(language_code)[0].format(message))

View File

@ -1591,6 +1591,16 @@ disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.google_assistant_sdk.*]
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.google_sheets.*]
check_untyped_defs = true
disallow_incomplete_defs = true