Improve config flow type hints in wolflink (#125313)

This commit is contained in:
epenet 2024-09-13 16:34:08 +02:00 committed by GitHub
parent ba856dac4e
commit 58f66e54f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,10 +1,10 @@
"""Config flow for Wolf SmartSet Service integration.""" """Config flow for Wolf SmartSet Service integration."""
import logging import logging
from typing import Any
from httpcore import ConnectError from httpcore import ConnectError
import voluptuous as vol import voluptuous as vol
from wolf_comm.models import Device
from wolf_comm.token_auth import InvalidAuth from wolf_comm.token_auth import InvalidAuth
from wolf_comm.wolf_client import WolfClient from wolf_comm.wolf_client import WolfClient
@ -26,14 +26,15 @@ class WolfLinkConfigFlow(ConfigFlow, domain=DOMAIN):
VERSION = 1 VERSION = 1
MINOR_VERSION = 2 MINOR_VERSION = 2
fetched_systems: list[Device]
def __init__(self) -> None: def __init__(self) -> None:
"""Initialize with empty username and password.""" """Initialize with empty username and password."""
self.username = None self.username: str | None = None
self.password = None self.password: str | None = None
self.fetched_systems = None
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, str] | None = None
) -> ConfigFlowResult: ) -> ConfigFlowResult:
"""Handle the initial step to get connection parameters.""" """Handle the initial step to get connection parameters."""
errors = {} errors = {}
@ -58,9 +59,11 @@ class WolfLinkConfigFlow(ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=USER_SCHEMA, errors=errors 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.""" """Allow user to select device from devices connected to specified account."""
errors = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:
device_name = user_input[DEVICE_NAME] device_name = user_input[DEVICE_NAME]
system = [ system = [