From 192b8ae6042f4d0112188753256993e936380256 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 5 Sep 2024 08:23:50 +0000 Subject: [PATCH] Improve config flow type hints in wolflink --- .../components/wolflink/config_flow.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/wolflink/config_flow.py b/homeassistant/components/wolflink/config_flow.py index a2678580a231fa..3c1b50eaa23ec7 100644 --- a/homeassistant/components/wolflink/config_flow.py +++ b/homeassistant/components/wolflink/config_flow.py @@ -1,10 +1,10 @@ """Config flow for Wolf SmartSet Service integration.""" import logging -from typing import Any from httpcore import ConnectError import voluptuous as vol +from wolf_comm.models import Device from wolf_comm.token_auth import InvalidAuth from wolf_comm.wolf_client import WolfClient @@ -25,14 +25,15 @@ class WolfLinkConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 1 + fetched_systems: list[Device] + def __init__(self) -> None: """Initialize with empty username and password.""" - self.username = None - self.password = None - self.fetched_systems = None + self.username: str | None = None + self.password: str | None = None async def async_step_user( - self, user_input: dict[str, Any] | None = None + self, user_input: dict[str, str] | None = None ) -> ConfigFlowResult: """Handle the initial step to get connection parameters.""" errors = {} @@ -57,16 +58,19 @@ async def async_step_user( step_id="user", data_schema=USER_SCHEMA, errors=errors ) - async def async_step_device(self, user_input=None): + async def async_step_device( + self, user_input: dict[str, str] | None = None + ) -> ConfigFlowResult: """Allow user to select device from devices connected to specified account.""" - errors = {} + errors: dict[str, str] = {} if user_input is not None: device_name = user_input[DEVICE_NAME] system = [ device for device in self.fetched_systems if device.name == device_name ] device_id = system[0].id - await self.async_set_unique_id(device_id) + # This should be investigated and possibly migrated to a string + await self.async_set_unique_id(device_id) # type: ignore[arg-type] self._abort_if_unique_id_configured() return self.async_create_entry( title=user_input[DEVICE_NAME],