From 285a7251dff3058c1e6bc021b466e9247065f9f6 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 31 May 2022 00:10:38 +0200 Subject: [PATCH] Adjust config-flow type hints in zwave_me (#72714) --- .../components/zwave_me/config_flow.py | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/zwave_me/config_flow.py b/homeassistant/components/zwave_me/config_flow.py index 4fee380ca48..9089e5514f5 100644 --- a/homeassistant/components/zwave_me/config_flow.py +++ b/homeassistant/components/zwave_me/config_flow.py @@ -1,4 +1,5 @@ """Config flow to configure ZWaveMe integration.""" +from __future__ import annotations import logging @@ -6,7 +7,9 @@ from url_normalize import url_normalize import voluptuous as vol from homeassistant import config_entries +from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.const import CONF_TOKEN, CONF_URL +from homeassistant.data_entry_flow import FlowResult from . import helpers from .const import DOMAIN @@ -17,13 +20,15 @@ _LOGGER = logging.getLogger(__name__) class ZWaveMeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """ZWaveMe integration config flow.""" - def __init__(self): + def __init__(self) -> None: """Initialize flow.""" - self.url = None - self.token = None - self.uuid = None + self.url: str | None = None + self.token: str | None = None + self.uuid: str | None = None - async def async_step_user(self, user_input=None): + async def async_step_user( + self, user_input: dict[str, str] | None = None + ) -> FlowResult: """Handle a flow initialized by the user or started with zeroconf.""" errors = {} placeholders = { @@ -55,6 +60,7 @@ class ZWaveMeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): if not self.url.startswith(("ws://", "wss://")): self.url = f"ws://{self.url}" self.url = url_normalize(self.url, default_scheme="ws") + assert self.url if self.uuid is None: self.uuid = await helpers.get_uuid(self.url, self.token) if self.uuid is not None: @@ -76,7 +82,9 @@ class ZWaveMeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_zeroconf(self, discovery_info): + async def async_step_zeroconf( + self, discovery_info: ZeroconfServiceInfo + ) -> FlowResult: """ Handle a discovered Z-Wave accessory - get url to pass into user step.