Improve type hints in homematicip_cloud (#87269)

This commit is contained in:
epenet 2023-02-03 15:52:14 +01:00 committed by GitHub
parent 527de22adf
commit 23a9b92a1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View file

@ -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]

View file

@ -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