From 23a9b92a1c477b1b70aeee4d04b9fe9cdc339073 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 3 Feb 2023 15:52:14 +0100 Subject: [PATCH] Improve type hints in homematicip_cloud (#87269) --- .../homematicip_cloud/config_flow.py | 18 ++++++++++++------ .../components/homematicip_cloud/hap.py | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/homematicip_cloud/config_flow.py b/homeassistant/components/homematicip_cloud/config_flow.py index 3fedff3f579..8581367d4ee 100644 --- a/homeassistant/components/homematicip_cloud/config_flow.py +++ b/homeassistant/components/homematicip_cloud/config_flow.py @@ -1,6 +1,8 @@ """Config flow to configure the HomematicIP Cloud component.""" from __future__ import annotations +from typing import Any + import voluptuous as vol from homeassistant import config_entries @@ -20,11 +22,15 @@ class HomematicipCloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): def __init__(self) -> None: """Initialize HomematicIP Cloud config flow.""" - async def async_step_user(self, user_input=None) -> FlowResult: + async def async_step_user( + self, user_input: dict[str, Any] | None = None + ) -> FlowResult: """Handle a flow initialized by the user.""" return await self.async_step_init(user_input) - async def async_step_init(self, user_input=None) -> FlowResult: + async def async_step_init( + self, user_input: dict[str, str] | None = None + ) -> FlowResult: """Handle a flow start.""" errors = {} @@ -55,7 +61,7 @@ class HomematicipCloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_link(self, user_input=None) -> FlowResult: + async def async_step_link(self, user_input: None = None) -> FlowResult: """Attempt to link with the HomematicIP Cloud access point.""" errors = {} @@ -65,9 +71,9 @@ class HomematicipCloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if authtoken: _LOGGER.info("Write config entry for HomematicIP Cloud") return self.async_create_entry( - title=self.auth.config.get(HMIPC_HAPID), + title=self.auth.config[HMIPC_HAPID], data={ - HMIPC_HAPID: self.auth.config.get(HMIPC_HAPID), + HMIPC_HAPID: self.auth.config[HMIPC_HAPID], HMIPC_AUTHTOKEN: authtoken, HMIPC_NAME: self.auth.config.get(HMIPC_NAME), }, @@ -77,7 +83,7 @@ class HomematicipCloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return self.async_show_form(step_id="link", errors=errors) - async def async_step_import(self, import_info) -> FlowResult: + async def async_step_import(self, import_info: dict[str, str]) -> FlowResult: """Import a new access point as a config entry.""" hapid = import_info[HMIPC_HAPID].replace("-", "").upper() authtoken = import_info[HMIPC_AUTHTOKEN] diff --git a/homeassistant/components/homematicip_cloud/hap.py b/homeassistant/components/homematicip_cloud/hap.py index cc4414c9069..b40b6ec56f6 100644 --- a/homeassistant/components/homematicip_cloud/hap.py +++ b/homeassistant/components/homematicip_cloud/hap.py @@ -27,7 +27,7 @@ class HomematicipAuth: auth: AsyncAuth - def __init__(self, hass, config) -> None: + def __init__(self, hass: HomeAssistant, config: dict[str, str]) -> None: """Initialize HomematicIP Cloud client registration.""" self.hass = hass self.config = config