Enable strict typing for google_assistant_sdk (#107306)
parent
fde7a6e9ef
commit
f5d5e1dcbb
|
@ -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.*
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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))
|
||||
|
|
10
mypy.ini
10
mypy.ini
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue