mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 03:07:50 +00:00
Improve type hints in hvv_departures config flow (#124902)
This commit is contained in:
parent
1906155c18
commit
febb382030
@ -49,10 +49,11 @@ class HVVDeparturesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
|
hub: GTIHub
|
||||||
|
data: dict[str, Any]
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Initialize component."""
|
"""Initialize component."""
|
||||||
self.hub: GTIHub | None = None
|
|
||||||
self.data: dict[str, Any] | None = None
|
|
||||||
self.stations: dict[str, Any] = {}
|
self.stations: dict[str, Any] = {}
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
@ -86,7 +87,9 @@ class HVVDeparturesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
step_id="user", data_schema=SCHEMA_STEP_USER, errors=errors
|
step_id="user", data_schema=SCHEMA_STEP_USER, errors=errors
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_station(self, user_input=None):
|
async def async_step_station(
|
||||||
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle the step where the user inputs his/her station."""
|
"""Handle the step where the user inputs his/her station."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
errors = {}
|
errors = {}
|
||||||
@ -116,7 +119,9 @@ class HVVDeparturesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
return self.async_show_form(step_id="station", data_schema=SCHEMA_STEP_STATION)
|
return self.async_show_form(step_id="station", data_schema=SCHEMA_STEP_STATION)
|
||||||
|
|
||||||
async def async_step_station_select(self, user_input=None):
|
async def async_step_station_select(
|
||||||
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle the step where the user inputs his/her station."""
|
"""Handle the step where the user inputs his/her station."""
|
||||||
|
|
||||||
schema = vol.Schema({vol.Required(CONF_STATION): vol.In(list(self.stations))})
|
schema = vol.Schema({vol.Required(CONF_STATION): vol.In(list(self.stations))})
|
||||||
@ -148,7 +153,9 @@ class OptionsFlowHandler(OptionsFlow):
|
|||||||
self.options = dict(config_entry.options)
|
self.options = dict(config_entry.options)
|
||||||
self.departure_filters: dict[str, Any] = {}
|
self.departure_filters: dict[str, Any] = {}
|
||||||
|
|
||||||
async def async_step_init(self, user_input=None):
|
async def async_step_init(
|
||||||
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Manage the options."""
|
"""Manage the options."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if not self.departure_filters:
|
if not self.departure_filters:
|
||||||
@ -177,7 +184,7 @@ class OptionsFlowHandler(OptionsFlow):
|
|||||||
if not errors:
|
if not errors:
|
||||||
self.departure_filters = {
|
self.departure_filters = {
|
||||||
str(i): departure_filter
|
str(i): departure_filter
|
||||||
for i, departure_filter in enumerate(departure_list.get("filter"))
|
for i, departure_filter in enumerate(departure_list["filter"])
|
||||||
}
|
}
|
||||||
|
|
||||||
if user_input is not None and not errors:
|
if user_input is not None and not errors:
|
||||||
@ -195,7 +202,7 @@ class OptionsFlowHandler(OptionsFlow):
|
|||||||
old_filter = [
|
old_filter = [
|
||||||
i
|
i
|
||||||
for (i, f) in self.departure_filters.items()
|
for (i, f) in self.departure_filters.items()
|
||||||
if f in self.config_entry.options.get(CONF_FILTER)
|
if f in self.config_entry.options[CONF_FILTER]
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
old_filter = []
|
old_filter = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user