Improve type hints in hvv_departures config flow (#124902)
This commit is contained in:
parent
1906155c18
commit
febb382030
1 changed files with 14 additions and 7 deletions
|
@ -49,10 +49,11 @@ class HVVDeparturesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
VERSION = 1
|
||||
|
||||
hub: GTIHub
|
||||
data: dict[str, Any]
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize component."""
|
||||
self.hub: GTIHub | None = None
|
||||
self.data: dict[str, Any] | None = None
|
||||
self.stations: dict[str, Any] = {}
|
||||
|
||||
async def async_step_user(
|
||||
|
@ -86,7 +87,9 @@ class HVVDeparturesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
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."""
|
||||
if user_input is not None:
|
||||
errors = {}
|
||||
|
@ -116,7 +119,9 @@ class HVVDeparturesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
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."""
|
||||
|
||||
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.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."""
|
||||
errors = {}
|
||||
if not self.departure_filters:
|
||||
|
@ -177,7 +184,7 @@ class OptionsFlowHandler(OptionsFlow):
|
|||
if not errors:
|
||||
self.departure_filters = {
|
||||
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:
|
||||
|
@ -195,7 +202,7 @@ class OptionsFlowHandler(OptionsFlow):
|
|||
old_filter = [
|
||||
i
|
||||
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:
|
||||
old_filter = []
|
||||
|
|
Loading…
Add table
Reference in a new issue