From febb3820309a9cb0cb4e8e6ee109d5500fde4bee Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:25:08 +0200 Subject: [PATCH] Improve type hints in hvv_departures config flow (#124902) --- .../components/hvv_departures/config_flow.py | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/hvv_departures/config_flow.py b/homeassistant/components/hvv_departures/config_flow.py index a02796dbffb..3e1b98d9a38 100644 --- a/homeassistant/components/hvv_departures/config_flow.py +++ b/homeassistant/components/hvv_departures/config_flow.py @@ -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 = []