From 5533e6416402eb27624c11be05bdfaaf9a08befd Mon Sep 17 00:00:00 2001 From: Grant Ellsworth Date: Sun, 10 May 2026 12:47:30 +0000 Subject: [PATCH] Add RepairsFlowResult TypeAlias --- homeassistant/components/anthropic/repairs.py | 7 ++-- .../assist_pipeline/repair_flows.py | 7 ++-- homeassistant/components/bthome/repairs.py | 7 ++-- homeassistant/components/cloud/repairs.py | 12 +++---- homeassistant/components/doorbird/repairs.py | 7 ++-- homeassistant/components/esphome/repairs.py | 9 +++-- homeassistant/components/hassio/repairs.py | 15 ++++----- .../components/homeassistant/repairs.py | 19 ++++++----- .../components/homewizard/repairs.py | 10 +++--- .../components/kitchen_sink/repairs.py | 13 +++++--- homeassistant/components/knx/repairs.py | 11 +++---- homeassistant/components/lg_thinq/repairs.py | 11 ++++--- homeassistant/components/mqtt/repairs.py | 11 +++---- homeassistant/components/ntfy/repairs.py | 11 ++++--- .../components/openweathermap/repairs.py | 7 ++-- homeassistant/components/opower/repairs.py | 7 ++-- homeassistant/components/repairs/__init__.py | 3 +- .../components/repairs/issue_handler.py | 18 ++++++---- homeassistant/components/repairs/models.py | 7 +++- homeassistant/components/shelly/repairs.py | 33 ++++++++++--------- .../components/synology_dsm/repairs.py | 13 +++++--- .../components/unifiprotect/repairs.py | 17 ++++++---- homeassistant/components/workday/repairs.py | 17 ++++++---- homeassistant/components/zeroconf/repairs.py | 7 ++-- .../repairs/network_settings_inconsistent.py | 9 +++-- homeassistant/components/zwave_js/repairs.py | 17 ++++++---- 26 files changed, 163 insertions(+), 142 deletions(-) diff --git a/homeassistant/components/anthropic/repairs.py b/homeassistant/components/anthropic/repairs.py index 45996c85867aa..de96d8e8d378b 100644 --- a/homeassistant/components/anthropic/repairs.py +++ b/homeassistant/components/anthropic/repairs.py @@ -7,8 +7,7 @@ from anthropic.resources.messages.messages import DEPRECATED_MODELS import voluptuous as vol -from homeassistant import data_entry_flow -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.config_entries import ConfigEntryState, ConfigSubentry from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError @@ -41,9 +40,7 @@ def __init__(self) -> None: self._current_subentry_id = None self._model_list_cache = None - async def async_step_init( - self, user_input: dict[str, str] - ) -> data_entry_flow.FlowResult: + async def async_step_init(self, user_input: dict[str, str]) -> RepairsFlowResult: """Handle the steps of a fix flow.""" if user_input.get(CONF_CHAT_MODEL): self._async_update_current_subentry(user_input) diff --git a/homeassistant/components/assist_pipeline/repair_flows.py b/homeassistant/components/assist_pipeline/repair_flows.py index ea1b3f4d83b52..12b726df9a955 100644 --- a/homeassistant/components/assist_pipeline/repair_flows.py +++ b/homeassistant/components/assist_pipeline/repair_flows.py @@ -5,8 +5,7 @@ import voluptuous as vol from homeassistant.components.assist_satellite import DOMAIN as ASSIST_SATELLITE_DOMAIN -from homeassistant.components.repairs import RepairsFlow -from homeassistant.data_entry_flow import FlowResult +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.helpers import entity_registry as er REQUIRED_KEYS = ("entity_id", "entity_uuid", "integration_name") @@ -21,14 +20,14 @@ def __init__(self, data: dict[str, str | int | float | None] | None) -> None: raise ValueError("Missing data") self._data = data - async def async_step_init(self, _: None = None) -> FlowResult: + async def async_step_init(self, _: None = None) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm_disable_entity() async def async_step_confirm_disable_entity( self, user_input: dict[str, str] | None = None, - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: entity_registry = er.async_get(self.hass) diff --git a/homeassistant/components/bthome/repairs.py b/homeassistant/components/bthome/repairs.py index d8d0bd53ad015..25824ea8f91bc 100644 --- a/homeassistant/components/bthome/repairs.py +++ b/homeassistant/components/bthome/repairs.py @@ -2,8 +2,7 @@ from typing import Any -from homeassistant import data_entry_flow -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.core import HomeAssistant from homeassistant.helpers import issue_registry as ir @@ -21,13 +20,13 @@ def __init__(self, entry_id: str, entry_title: str) -> None: async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the initial step of the repair flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, Any] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle confirmation, remove the bindkey, and reload the entry.""" if user_input is not None: entry = self.hass.config_entries.async_get_entry(self._entry_id) diff --git a/homeassistant/components/cloud/repairs.py b/homeassistant/components/cloud/repairs.py index 748cf0ba49902..5af9bc5d1ea7b 100644 --- a/homeassistant/components/cloud/repairs.py +++ b/homeassistant/components/cloud/repairs.py @@ -8,10 +8,10 @@ from homeassistant.components.repairs import ( ConfirmRepairFlow, RepairsFlow, + RepairsFlowResult, repairs_flow_manager, ) from homeassistant.core import HomeAssistant, callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import issue_registry as ir from .const import DATA_CLOUD, DOMAIN @@ -50,14 +50,14 @@ class LegacySubscriptionRepairFlow(RepairsFlow): wait_task: asyncio.Task | None = None _data: SubscriptionInfo | None = None - async def async_step_init(self, _: None = None) -> FlowResult: + async def async_step_init(self, _: None = None) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm_change_plan() async def async_step_confirm_change_plan( self, user_input: dict[str, str] | None = None, - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: return await self.async_step_change_plan() @@ -66,7 +66,7 @@ async def async_step_confirm_change_plan( step_id="confirm_change_plan", data_schema=vol.Schema({}) ) - async def async_step_change_plan(self, _: None = None) -> FlowResult: + async def async_step_change_plan(self, _: None = None) -> RepairsFlowResult: """Wait for the user to authorize the app installation.""" cloud = self.hass.data[DATA_CLOUD] @@ -107,11 +107,11 @@ async def _async_wait_for_plan_change() -> None: return self.async_external_step_done(next_step_id="complete") - async def async_step_complete(self, _: None = None) -> FlowResult: + async def async_step_complete(self, _: None = None) -> RepairsFlowResult: """Handle the final step of a fix flow.""" return self.async_create_entry(data={}) - async def async_step_timeout(self, _: None = None) -> FlowResult: + async def async_step_timeout(self, _: None = None) -> RepairsFlowResult: """Handle the final step of a fix flow.""" return self.async_abort(reason="operation_took_too_long") diff --git a/homeassistant/components/doorbird/repairs.py b/homeassistant/components/doorbird/repairs.py index 7745dcf985d9c..a14b5a0dc1b23 100644 --- a/homeassistant/components/doorbird/repairs.py +++ b/homeassistant/components/doorbird/repairs.py @@ -2,8 +2,7 @@ import voluptuous as vol -from homeassistant import data_entry_flow -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.core import HomeAssistant from homeassistant.helpers import issue_registry as ir @@ -17,13 +16,13 @@ def __init__(self, entry_id: str) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: self.hass.config_entries.async_schedule_reload(self.entry_id) diff --git a/homeassistant/components/esphome/repairs.py b/homeassistant/components/esphome/repairs.py index 8fe7884845ec7..753eda3ad3bce 100644 --- a/homeassistant/components/esphome/repairs.py +++ b/homeassistant/components/esphome/repairs.py @@ -4,8 +4,7 @@ import voluptuous as vol -from homeassistant import data_entry_flow -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.core import HomeAssistant from .manager import async_replace_device @@ -43,7 +42,7 @@ def stored_mac(self) -> str: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return self.async_show_menu( step_id="init", @@ -52,7 +51,7 @@ async def async_step_init( async def async_step_migrate( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the migrate step of a fix flow.""" if user_input is None: return self.async_show_form( @@ -66,7 +65,7 @@ async def async_step_migrate( async def async_step_manual( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the manual step of a fix flow.""" if user_input is None: return self.async_show_form( diff --git a/homeassistant/components/hassio/repairs.py b/homeassistant/components/hassio/repairs.py index d4887470cdbf2..d199678acee35 100644 --- a/homeassistant/components/hassio/repairs.py +++ b/homeassistant/components/hassio/repairs.py @@ -8,10 +8,9 @@ from aiohasupervisor.models import ContextType import voluptuous as vol -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.const import ATTR_NAME from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from . import get_addons_list from .const import ( @@ -77,7 +76,7 @@ def description_placeholders(self) -> dict[str, str] | None: return placeholders or None - def _async_form_for_suggestion(self, suggestion: Suggestion) -> FlowResult: + def _async_form_for_suggestion(self, suggestion: Suggestion) -> RepairsFlowResult: """Return form for suggestion.""" return self.async_show_form( step_id=suggestion.key, @@ -86,7 +85,7 @@ def _async_form_for_suggestion(self, suggestion: Suggestion) -> FlowResult: last_step=True, ) - async def async_step_init(self, _: None = None) -> FlowResult: + async def async_step_init(self, _: None = None) -> RepairsFlowResult: """Handle the first step of a fix flow.""" # Out of sync with supervisor, issue is resolved or not fixable. Remove it if not self.issue or not self.issue.suggestions: @@ -108,7 +107,7 @@ async def async_step_init(self, _: None = None) -> FlowResult: # Always show a form for one suggestion to explain to user what's happening return self._async_form_for_suggestion(self.issue.suggestions[0]) - async def async_step_fix_menu(self, _: None = None) -> FlowResult: + async def async_step_fix_menu(self, _: None = None) -> RepairsFlowResult: """Show the fix menu.""" assert self.issue @@ -120,7 +119,7 @@ async def async_step_fix_menu(self, _: None = None) -> FlowResult: async def _async_step_apply_suggestion( self, suggestion: Suggestion, confirmed: bool = False - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle applying a suggestion as a flow step. Optionally request confirmation.""" if not confirmed and suggestion.key in SUGGESTION_CONFIRMATION_REQUIRED: return self._async_form_for_suggestion(suggestion) @@ -137,13 +136,13 @@ def _async_step( suggestion: Suggestion, ) -> Callable[ [SupervisorIssueRepairFlow, dict[str, str] | None], - Coroutine[Any, Any, FlowResult], + Coroutine[Any, Any, RepairsFlowResult], ]: """Generate a step handler for a suggestion.""" async def _async_step( self: SupervisorIssueRepairFlow, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle a flow step for a suggestion.""" return await self._async_step_apply_suggestion( suggestion, confirmed=user_input is not None diff --git a/homeassistant/components/homeassistant/repairs.py b/homeassistant/components/homeassistant/repairs.py index efc6b7f4cc5f1..5f770d7bdf410 100644 --- a/homeassistant/components/homeassistant/repairs.py +++ b/homeassistant/components/homeassistant/repairs.py @@ -1,8 +1,11 @@ """Repairs for Home Assistant.""" -from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow +from homeassistant.components.repairs import ( + ConfirmRepairFlow, + RepairsFlow, + RepairsFlowResult, +) from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import issue_registry as ir from .const import DOMAIN @@ -18,7 +21,7 @@ def __init__(self, data: dict[str, str]) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return self.async_show_menu( step_id="init", @@ -28,7 +31,7 @@ async def async_step_init( async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" entries = self.hass.config_entries.async_entries(self.domain) for entry in entries: @@ -37,7 +40,7 @@ async def async_step_confirm( async def async_step_ignore( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the ignore step of a fix flow.""" ir.async_get(self.hass).async_ignore( DOMAIN, f"integration_not_found.{self.domain}", True @@ -58,7 +61,7 @@ def __init__(self, data: dict[str, str]) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return self.async_show_menu( step_id="init", @@ -68,14 +71,14 @@ async def async_step_init( async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" await self.hass.config_entries.async_remove(self.entry_id) return self.async_create_entry(data={}) async def async_step_ignore( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the ignore step of a fix flow.""" ir.async_get(self.hass).async_ignore( DOMAIN, f"orphaned_ignored_entry.{self.entry_id}", True diff --git a/homeassistant/components/homewizard/repairs.py b/homeassistant/components/homewizard/repairs.py index d47d19e051cc8..cc6e719f580a1 100644 --- a/homeassistant/components/homewizard/repairs.py +++ b/homeassistant/components/homewizard/repairs.py @@ -1,11 +1,9 @@ """Repairs for HomeWizard integration.""" -from homeassistant import data_entry_flow -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_IP_ADDRESS, CONF_TOKEN from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from .config_flow import async_request_token @@ -19,14 +17,14 @@ def __init__(self, entry: ConfigEntry) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: @@ -38,7 +36,7 @@ async def async_step_confirm( async def async_step_authorize( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the authorize step of a fix flow.""" ip_address = self.entry.data[CONF_IP_ADDRESS] diff --git a/homeassistant/components/kitchen_sink/repairs.py b/homeassistant/components/kitchen_sink/repairs.py index 5bcf9d17a8cf8..ef86301070086 100644 --- a/homeassistant/components/kitchen_sink/repairs.py +++ b/homeassistant/components/kitchen_sink/repairs.py @@ -2,8 +2,11 @@ import voluptuous as vol -from homeassistant import data_entry_flow -from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow +from homeassistant.components.repairs import ( + ConfirmRepairFlow, + RepairsFlow, + RepairsFlowResult, +) from homeassistant.core import HomeAssistant @@ -12,14 +15,14 @@ class DemoFixFlow(RepairsFlow): async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: return self.async_create_entry(data={}) @@ -32,7 +35,7 @@ class DemoColdTeaFixFlow(RepairsFlow): async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return self.async_abort(reason="not_tea_time") diff --git a/homeassistant/components/knx/repairs.py b/homeassistant/components/knx/repairs.py index 00bb6b0970a9b..42b5e75f52f6a 100644 --- a/homeassistant/components/knx/repairs.py +++ b/homeassistant/components/knx/repairs.py @@ -8,8 +8,7 @@ from xknx.exceptions.exception import InvalidSecureConfiguration from xknx.telegram import GroupAddress, IndividualAddress, Telegram -from homeassistant import data_entry_flow -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import issue_registry as ir, selector from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -110,13 +109,13 @@ class DataSecureGroupIssueRepairFlow(RepairsFlow): async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_secure_knxkeys() async def async_step_secure_knxkeys( self, user_input: dict[str, Any] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Manage upload of new KNX Keyring file.""" errors: dict[str, str] = {} @@ -152,9 +151,7 @@ async def async_step_secure_knxkeys( ) @callback - def finish_flow( - self, new_entry_data: KNXConfigEntryData - ) -> data_entry_flow.FlowResult: + def finish_flow(self, new_entry_data: KNXConfigEntryData) -> RepairsFlowResult: """Finish the repair flow. Reload the config entry.""" knx_config_entries = self.hass.config_entries.async_entries(DOMAIN) if knx_config_entries: diff --git a/homeassistant/components/lg_thinq/repairs.py b/homeassistant/components/lg_thinq/repairs.py index 391f43cf50432..c41c2dc051eb8 100644 --- a/homeassistant/components/lg_thinq/repairs.py +++ b/homeassistant/components/lg_thinq/repairs.py @@ -2,8 +2,11 @@ import voluptuous as vol -from homeassistant import data_entry_flow -from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow +from homeassistant.components.repairs import ( + ConfirmRepairFlow, + RepairsFlow, + RepairsFlowResult, +) from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er @@ -18,13 +21,13 @@ def __init__(self, data: dict[str, str]) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: entity_registry = er.async_get(self.hass) diff --git a/homeassistant/components/mqtt/repairs.py b/homeassistant/components/mqtt/repairs.py index 8538515118e8a..38ac997d073e8 100644 --- a/homeassistant/components/mqtt/repairs.py +++ b/homeassistant/components/mqtt/repairs.py @@ -4,8 +4,7 @@ import voluptuous as vol -from homeassistant import data_entry_flow -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.const import CONF_PORT, CONF_PROTOCOL from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr @@ -29,13 +28,13 @@ def __init__(self, entry_id: str, subentry_id: str, name: str) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: device_registry = dr.async_get(self.hass) @@ -67,13 +66,13 @@ def __init__(self, entry_id: str, broker: str, protocol: str) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: entry = self.hass.config_entries.async_get_entry(self.entry_id) diff --git a/homeassistant/components/ntfy/repairs.py b/homeassistant/components/ntfy/repairs.py index 6cba53ac3b11e..6f8f59d4cafd9 100644 --- a/homeassistant/components/ntfy/repairs.py +++ b/homeassistant/components/ntfy/repairs.py @@ -2,8 +2,11 @@ import voluptuous as vol -from homeassistant import data_entry_flow -from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow +from homeassistant.components.repairs import ( + ConfirmRepairFlow, + RepairsFlow, + RepairsFlowResult, +) from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er @@ -20,14 +23,14 @@ def __init__(self, data: dict[str, str]) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Init repair flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Confirm repair flow.""" if user_input is not None: er.async_get(self.hass).async_update_entity( diff --git a/homeassistant/components/openweathermap/repairs.py b/homeassistant/components/openweathermap/repairs.py index 9cd3ba075b8a6..6301405ccbc04 100644 --- a/homeassistant/components/openweathermap/repairs.py +++ b/homeassistant/components/openweathermap/repairs.py @@ -2,8 +2,7 @@ from typing import TYPE_CHECKING, cast -from homeassistant import data_entry_flow -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.const import CONF_API_KEY, CONF_MODE from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import issue_registry as ir @@ -25,13 +24,13 @@ def __init__(self, entry: OpenweathermapConfigEntry) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return self.async_show_form(step_id="migrate") async def async_step_migrate( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the migrate step of a fix flow.""" errors, description_placeholders = {}, {} new_options = {**self.entry.options, CONF_MODE: OWM_MODE_V30} diff --git a/homeassistant/components/opower/repairs.py b/homeassistant/components/opower/repairs.py index 93a320311e40c..9526569b90134 100644 --- a/homeassistant/components/opower/repairs.py +++ b/homeassistant/components/opower/repairs.py @@ -1,8 +1,7 @@ """Repairs for Opower.""" -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult class UnsupportedUtilityFixFlow(RepairsFlow): @@ -16,13 +15,13 @@ def __init__(self, data: dict[str, str]) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: await self.hass.config_entries.async_remove(self._entry_id) diff --git a/homeassistant/components/repairs/__init__.py b/homeassistant/components/repairs/__init__.py index 9a7b0579e6f39..99bd11597f8e5 100644 --- a/homeassistant/components/repairs/__init__.py +++ b/homeassistant/components/repairs/__init__.py @@ -7,13 +7,14 @@ from . import issue_handler, websocket_api from .const import DOMAIN from .issue_handler import ConfirmRepairFlow, RepairsFlowManager -from .models import RepairsFlow +from .models import RepairsFlow, RepairsFlowResult __all__ = [ "DOMAIN", "ConfirmRepairFlow", "RepairsFlow", "RepairsFlowManager", + "RepairsFlowResult", "repairs_flow_manager", ] CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) diff --git a/homeassistant/components/repairs/issue_handler.py b/homeassistant/components/repairs/issue_handler.py index 2a5ccb5f040bd..3e7128d320c1d 100644 --- a/homeassistant/components/repairs/issue_handler.py +++ b/homeassistant/components/repairs/issue_handler.py @@ -13,7 +13,7 @@ ) from .const import DOMAIN -from .models import RepairsFlow, RepairsProtocol +from .models import RepairsFlow, RepairsFlowResult, RepairsProtocol class ConfirmRepairFlow(RepairsFlow): @@ -21,13 +21,13 @@ class ConfirmRepairFlow(RepairsFlow): async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: return self.async_create_entry(data={}) @@ -44,7 +44,9 @@ async def async_step_confirm( ) -class RepairsFlowManager(data_entry_flow.FlowManager): +class RepairsFlowManager( + data_entry_flow.FlowManager[data_entry_flow.FlowContext, RepairsFlowResult, str] +): """Manage repairs flows.""" async def async_create_flow( @@ -78,8 +80,12 @@ async def async_create_flow( return flow async def async_finish_flow( - self, flow: data_entry_flow.FlowHandler, result: data_entry_flow.FlowResult - ) -> data_entry_flow.FlowResult: + self, + flow: data_entry_flow.FlowHandler[ + data_entry_flow.FlowContext, RepairsFlowResult, str + ], + result: RepairsFlowResult, + ) -> RepairsFlowResult: """Complete a fix flow. This method is called when a flow step returns FlowResultType.ABORT or diff --git a/homeassistant/components/repairs/models.py b/homeassistant/components/repairs/models.py index f79e7d1e1faaa..bdaee67fe1f84 100644 --- a/homeassistant/components/repairs/models.py +++ b/homeassistant/components/repairs/models.py @@ -5,8 +5,13 @@ from homeassistant import data_entry_flow from homeassistant.core import HomeAssistant +# Placeholder TypeAlias for future TypedDict to handle next_flow. +RepairsFlowResult = data_entry_flow.FlowResult[data_entry_flow.FlowContext, str] -class RepairsFlow(data_entry_flow.FlowHandler): + +class RepairsFlow( + data_entry_flow.FlowHandler[data_entry_flow.FlowContext, RepairsFlowResult, str] +): """Handle a flow for fixing an issue.""" issue_id: str diff --git a/homeassistant/components/shelly/repairs.py b/homeassistant/components/shelly/repairs.py index 73c3af9890ccc..02998088bef09 100644 --- a/homeassistant/components/shelly/repairs.py +++ b/homeassistant/components/shelly/repairs.py @@ -9,8 +9,11 @@ from awesomeversion import AwesomeVersion import voluptuous as vol -from homeassistant import data_entry_flow -from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow +from homeassistant.components.repairs import ( + ConfirmRepairFlow, + RepairsFlow, + RepairsFlowResult, +) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import issue_registry as ir @@ -206,7 +209,7 @@ class CoiotConfigureFlow(ShellyBlockRepairsFlow): async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" issue_registry = ir.async_get(self.hass) description_placeholders = None @@ -220,7 +223,7 @@ async def async_step_init( async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" coiot_addr = await get_coiot_address(self.hass) coiot_port = get_coiot_port(self.hass) @@ -236,7 +239,7 @@ async def async_step_confirm( async def async_step_ignore( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the ignore step of a fix flow.""" ir.async_ignore_issue(self.hass, DOMAIN, self.issue_id, True) return self.async_abort(reason="issue_ignored") @@ -251,13 +254,13 @@ def __init__(self, device: RpcDevice) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: return await self._async_step_confirm() @@ -273,7 +276,7 @@ async def async_step_confirm( description_placeholders=description_placeholders, ) - async def _async_step_confirm(self) -> data_entry_flow.FlowResult: + async def _async_step_confirm(self) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" raise NotImplementedError @@ -281,13 +284,13 @@ async def _async_step_confirm(self) -> data_entry_flow.FlowResult: class FirmwareUpdateFlow(ShellyRpcRepairsFlow): """Handler for Firmware Update flow.""" - async def _async_step_confirm(self) -> data_entry_flow.FlowResult: + async def _async_step_confirm(self) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" return await self.async_step_update_firmware() async def async_step_update_firmware( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if not self._device.status["sys"]["available_updates"]: return self.async_abort(reason="update_not_available") @@ -302,13 +305,13 @@ async def async_step_update_firmware( class DisableOutboundWebSocketFlow(ShellyRpcRepairsFlow): """Handler for Disable Outbound WebSocket flow.""" - async def _async_step_confirm(self) -> data_entry_flow.FlowResult: + async def _async_step_confirm(self) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" return await self.async_step_disable_outbound_websocket() async def async_step_disable_outbound_websocket( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" try: result = await self._device.ws_setconfig( @@ -332,7 +335,7 @@ def __init__(self, device: RpcDevice, issue_id: str) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" issue_registry = ir.async_get(self.hass) description_placeholders = None @@ -346,7 +349,7 @@ async def async_step_init( async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" try: result = await self._device.wifi_setconfig(ap_enable=False) @@ -359,7 +362,7 @@ async def async_step_confirm( async def async_step_ignore( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the ignore step of a fix flow.""" ir.async_ignore_issue(self.hass, DOMAIN, self.issue_id, True) return self.async_abort(reason="issue_ignored") diff --git a/homeassistant/components/synology_dsm/repairs.py b/homeassistant/components/synology_dsm/repairs.py index 7d8532c0af3d0..2e425b18c6129 100644 --- a/homeassistant/components/synology_dsm/repairs.py +++ b/homeassistant/components/synology_dsm/repairs.py @@ -7,8 +7,11 @@ from synology_dsm.api.file_station.models import SynoFileSharedFolder import voluptuous as vol -from homeassistant import data_entry_flow -from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow +from homeassistant.components.repairs import ( + ConfirmRepairFlow, + RepairsFlow, + RepairsFlowResult, +) from homeassistant.core import HomeAssistant from homeassistant.helpers import issue_registry as ir from homeassistant.helpers.selector import ( @@ -41,7 +44,7 @@ def __init__(self, entry: SynologyDSMConfigEntry, issue_id: str) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return self.async_show_menu( @@ -53,7 +56,7 @@ async def async_step_init( async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" syno_data = self.entry.runtime_data @@ -99,7 +102,7 @@ async def async_step_confirm( async def async_step_ignore( self, _: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" ir.async_ignore_issue(self.hass, DOMAIN, self.issue_id, True) return self.async_abort(reason="ignored") diff --git a/homeassistant/components/unifiprotect/repairs.py b/homeassistant/components/unifiprotect/repairs.py index 54c10e53de980..833a91b2dd277 100644 --- a/homeassistant/components/unifiprotect/repairs.py +++ b/homeassistant/components/unifiprotect/repairs.py @@ -6,8 +6,11 @@ from uiprotect.data import Bootstrap, Camera import voluptuous as vol -from homeassistant import data_entry_flow -from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow +from homeassistant.components.repairs import ( + ConfirmRepairFlow, + RepairsFlow, + RepairsFlowResult, +) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import issue_registry as ir @@ -45,14 +48,14 @@ class CloudAccountRepair(ProtectRepair): async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" if user_input is None: @@ -115,14 +118,14 @@ async def _enable_rtsp(self) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_start() async def async_step_start( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" if user_input is None: @@ -147,7 +150,7 @@ async def async_step_start( async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: return self.async_create_entry(data={}) diff --git a/homeassistant/components/workday/repairs.py b/homeassistant/components/workday/repairs.py index a340eaf9931cf..9c4e452771e55 100644 --- a/homeassistant/components/workday/repairs.py +++ b/homeassistant/components/workday/repairs.py @@ -5,8 +5,11 @@ from holidays import list_supported_countries import voluptuous as vol -from homeassistant import data_entry_flow -from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow +from homeassistant.components.repairs import ( + ConfirmRepairFlow, + RepairsFlow, + RepairsFlowResult, +) from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_COUNTRY from homeassistant.core import HomeAssistant @@ -31,7 +34,7 @@ def __init__(self, entry: ConfigEntry, country: str | None) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" if self.country: return await self.async_step_province() @@ -39,7 +42,7 @@ async def async_step_init( async def async_step_country( self, user_input: dict[str, Any] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the country step of a fix flow.""" if user_input is not None: all_countries = list_supported_countries(include_aliases=False) @@ -73,7 +76,7 @@ async def async_step_country( async def async_step_province( self, user_input: dict[str, Any] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the province step of a fix flow.""" if user_input is not None: user_input.setdefault(CONF_PROVINCE, None) @@ -121,13 +124,13 @@ def __init__( async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_fix_remove_holiday() async def async_step_fix_remove_holiday( self, user_input: dict[str, Any] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the options step of a fix flow.""" errors: dict[str, str] = {} if user_input: diff --git a/homeassistant/components/zeroconf/repairs.py b/homeassistant/components/zeroconf/repairs.py index 3054304f48da2..4946ef6f57f10 100644 --- a/homeassistant/components/zeroconf/repairs.py +++ b/homeassistant/components/zeroconf/repairs.py @@ -1,11 +1,10 @@ """Repairs for the zeroconf integration.""" -from homeassistant import data_entry_flow from homeassistant.components.homeassistant import ( DOMAIN as HOMEASSISTANT_DOMAIN, SERVICE_HOMEASSISTANT_RESTART, ) -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import instance_id, issue_registry as ir @@ -22,13 +21,13 @@ def _async_get_placeholders(self) -> dict[str, str]: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the initial step.""" return await self.async_step_confirm_recreate() async def async_step_confirm_recreate( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step.""" if user_input is not None: await instance_id.async_recreate(self.hass) diff --git a/homeassistant/components/zha/repairs/network_settings_inconsistent.py b/homeassistant/components/zha/repairs/network_settings_inconsistent.py index 89c253bbe34dc..3cdb6a92954c3 100644 --- a/homeassistant/components/zha/repairs/network_settings_inconsistent.py +++ b/homeassistant/components/zha/repairs/network_settings_inconsistent.py @@ -5,10 +5,9 @@ from zigpy.backups import NetworkBackup -from homeassistant.components.repairs import RepairsFlow +from homeassistant.components.repairs import RepairsFlow, RepairsFlowResult from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import issue_registry as ir from homeassistant.helpers.json import json_dumps from homeassistant.util.json import json_loads_object @@ -122,7 +121,7 @@ def __init__(self, hass: HomeAssistant, data: dict[str, Any]) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return self.async_show_menu( step_id="init", @@ -134,7 +133,7 @@ async def async_step_init( async def async_step_use_new_settings( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Step to use the new settings found on the radio.""" async with self._radio_mgr.create_zigpy_app(connect=False) as app: app.backups.add_backup(self._new_state) @@ -144,7 +143,7 @@ async def async_step_use_new_settings( async def async_step_restore_old_settings( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> RepairsFlowResult: """Step to restore the most recent backup.""" await self._radio_mgr.restore_backup(self._old_state) diff --git a/homeassistant/components/zwave_js/repairs.py b/homeassistant/components/zwave_js/repairs.py index 56f09409722b5..da8dd0e22efe3 100644 --- a/homeassistant/components/zwave_js/repairs.py +++ b/homeassistant/components/zwave_js/repairs.py @@ -1,7 +1,10 @@ """Repairs for Z-Wave JS.""" -from homeassistant import data_entry_flow -from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow +from homeassistant.components.repairs import ( + ConfirmRepairFlow, + RepairsFlow, + RepairsFlowResult, +) from homeassistant.core import HomeAssistant from homeassistant.helpers import issue_registry as ir @@ -21,7 +24,7 @@ def __init__(self, data: dict[str, str]) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return self.async_show_menu( menu_options=["confirm", "ignore"], @@ -30,7 +33,7 @@ async def async_step_init( async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" try: node = async_get_node_from_device_id(self.hass, self.device_id) @@ -44,7 +47,7 @@ async def async_step_confirm( async def async_step_ignore( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the ignore step of a fix flow.""" ir.async_get(self.hass).async_ignore( DOMAIN, f"device_config_file_changed.{self.device_id}", True @@ -83,13 +86,13 @@ def __init__(self, data: dict[str, str]) -> None: async def async_step_init( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the first step of a fix flow.""" return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> data_entry_flow.FlowResult: + ) -> RepairsFlowResult: """Handle the confirm step of a fix flow.""" if user_input is not None: config_entry = self.hass.config_entries.async_get_entry(