Adjust config-flow type hints in motion_blinds (#72444)

This commit is contained in:
epenet 2022-05-30 16:30:41 +02:00 committed by GitHub
parent c48591ff29
commit 5273e3ea9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,8 @@
"""Config flow to configure Motion Blinds using their WLAN API.""" """Config flow to configure Motion Blinds using their WLAN API."""
from __future__ import annotations
from typing import Any
from motionblinds import MotionDiscovery from motionblinds import MotionDiscovery
import voluptuous as vol import voluptuous as vol
@ -33,9 +37,11 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
"""Init object.""" """Init object."""
self.config_entry = config_entry self.config_entry = config_entry
async def async_step_init(self, user_input=None): async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Manage the options.""" """Manage the options."""
errors = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:
return self.async_create_entry(title="", data=user_input) return self.async_create_entry(title="", data=user_input)
@ -60,15 +66,17 @@ class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 1 VERSION = 1
def __init__(self): def __init__(self) -> None:
"""Initialize the Motion Blinds flow.""" """Initialize the Motion Blinds flow."""
self._host = None self._host: str | None = None
self._ips = [] self._ips: list[str] = []
self._config_settings = None self._config_settings = None
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow(config_entry) -> OptionsFlowHandler: def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
) -> OptionsFlowHandler:
"""Get the options flow.""" """Get the options flow."""
return OptionsFlowHandler(config_entry) return OptionsFlowHandler(config_entry)
@ -87,7 +95,9 @@ class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self._host = discovery_info.ip self._host = discovery_info.ip
return await self.async_step_connect() return await self.async_step_connect()
async def async_step_user(self, user_input=None): async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -114,7 +124,9 @@ class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=CONFIG_SCHEMA, errors=errors step_id="user", data_schema=CONFIG_SCHEMA, errors=errors
) )
async def async_step_select(self, user_input=None): async def async_step_select(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle multiple motion gateways found.""" """Handle multiple motion gateways found."""
if user_input is not None: if user_input is not None:
self._host = user_input["select_ip"] self._host = user_input["select_ip"]
@ -124,9 +136,11 @@ class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_show_form(step_id="select", data_schema=select_schema) return self.async_show_form(step_id="select", data_schema=select_schema)
async def async_step_connect(self, user_input=None): async def async_step_connect(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Connect to the Motion Gateway.""" """Connect to the Motion Gateway."""
errors = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:
key = user_input[CONF_API_KEY] key = user_input[CONF_API_KEY]