From 6971bb8f5bce2183dccb2e0ee7c3845a14dffd94 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Jun 2022 11:15:31 +0200 Subject: [PATCH] Adjust config-flow type hints in vera (#72409) * Adjust config-flow type hints in vera * Reduce size of PR --- homeassistant/components/vera/config_flow.py | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/vera/config_flow.py b/homeassistant/components/vera/config_flow.py index 319dcd031d0..c300f599faa 100644 --- a/homeassistant/components/vera/config_flow.py +++ b/homeassistant/components/vera/config_flow.py @@ -14,6 +14,7 @@ from homeassistant import config_entries from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_EXCLUDE, CONF_LIGHTS, CONF_SOURCE from homeassistant.core import callback +from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import entity_registry as er from .const import CONF_CONTROLLER, CONF_LEGACY_UNIQUE_ID, DOMAIN @@ -37,12 +38,14 @@ def list_to_str(data: list[Any]) -> str: return " ".join([str(i) for i in data]) -def new_options(lights: list[int], exclude: list[int]) -> dict: +def new_options(lights: list[int], exclude: list[int]) -> dict[str, list[int]]: """Create a standard options object.""" return {CONF_LIGHTS: lights, CONF_EXCLUDE: exclude} -def options_schema(options: Mapping[str, Any] = None) -> dict: +def options_schema( + options: Mapping[str, Any] | None = None +) -> dict[vol.Optional, type[str]]: """Return options schema.""" options = options or {} return { @@ -57,7 +60,7 @@ def options_schema(options: Mapping[str, Any] = None) -> dict: } -def options_data(user_input: dict) -> dict: +def options_data(user_input: dict[str, str]) -> dict[str, list[int]]: """Return options dict.""" return new_options( str_to_int_list(user_input.get(CONF_LIGHTS, "")), @@ -72,7 +75,10 @@ class OptionsFlowHandler(config_entries.OptionsFlow): """Init object.""" self.config_entry = config_entry - async def async_step_init(self, user_input: dict = None): + async def async_step_init( + self, + user_input: dict[str, str] | None = None, + ) -> FlowResult: """Manage the options.""" if user_input is not None: return self.async_create_entry( @@ -95,7 +101,9 @@ class VeraFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Get the options flow.""" return OptionsFlowHandler(config_entry) - async def async_step_user(self, user_input: dict = None): + async def async_step_user( + self, user_input: dict[str, Any] | None = None + ) -> FlowResult: """Handle user initiated flow.""" if user_input is not None: return await self.async_step_finish( @@ -114,7 +122,7 @@ class VeraFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ), ) - async def async_step_import(self, config: dict): + async def async_step_import(self, config: dict[str, Any]) -> FlowResult: """Handle a flow initialized by import.""" # If there are entities with the legacy unique_id, then this imported config @@ -139,7 +147,7 @@ class VeraFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): } ) - async def async_step_finish(self, config: dict): + async def async_step_finish(self, config: dict[str, Any]) -> FlowResult: """Validate and create config entry.""" base_url = config[CONF_CONTROLLER] = config[CONF_CONTROLLER].rstrip("/") controller = pv.VeraController(base_url)