From 00ee2b4478a04cf009a17d7217d5ee6ba849227b Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 8 Oct 2024 08:06:05 +0200 Subject: [PATCH] Enable strict typing for openai_conversation (#127854) --- .strict-typing | 1 + .../components/openai_conversation/config_flow.py | 7 ++++--- mypy.ini | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.strict-typing b/.strict-typing index 0a81bc4abfb..2613ecf5bbb 100644 --- a/.strict-typing +++ b/.strict-typing @@ -345,6 +345,7 @@ homeassistant.components.oncue.* homeassistant.components.onewire.* homeassistant.components.onkyo.* homeassistant.components.open_meteo.* +homeassistant.components.openai_conversation.* homeassistant.components.openexchangerates.* homeassistant.components.opensky.* homeassistant.components.openuv.* diff --git a/homeassistant/components/openai_conversation/config_flow.py b/homeassistant/components/openai_conversation/config_flow.py index 9a2b1b6fa79..c6b8487ad0d 100644 --- a/homeassistant/components/openai_conversation/config_flow.py +++ b/homeassistant/components/openai_conversation/config_flow.py @@ -26,6 +26,7 @@ from homeassistant.helpers.selector import ( SelectSelectorConfig, TemplateSelector, ) +from homeassistant.helpers.typing import VolDictType from .const import ( CONF_CHAT_MODEL, @@ -79,7 +80,7 @@ class OpenAIConfigFlow(ConfigFlow, domain=DOMAIN): step_id="user", data_schema=STEP_USER_DATA_SCHEMA ) - errors = {} + errors: dict[str, str] = {} try: await validate_input(self.hass, user_input) @@ -150,7 +151,7 @@ class OpenAIOptionsFlow(OptionsFlow): def openai_config_option_schema( hass: HomeAssistant, options: dict[str, Any] | MappingProxyType[str, Any], -) -> dict: +) -> VolDictType: """Return a schema for OpenAI completion options.""" hass_apis: list[SelectOptionDict] = [ SelectOptionDict( @@ -166,7 +167,7 @@ def openai_config_option_schema( for api in llm.async_get_apis(hass) ) - schema = { + schema: VolDictType = { vol.Optional( CONF_PROMPT, description={ diff --git a/mypy.ini b/mypy.ini index 4e49c68f89d..5cd3a05a119 100644 --- a/mypy.ini +++ b/mypy.ini @@ -3205,6 +3205,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.openai_conversation.*] +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.openexchangerates.*] check_untyped_defs = true disallow_incomplete_defs = true