mirror of
https://github.com/home-assistant/core.git
synced 2025-08-01 09:38:21 +00:00
Remove result from FlowResult (#149202)
This commit is contained in:
parent
f7eacaa48d
commit
42101dd432
@ -33,7 +33,10 @@ class AuthFlowContext(FlowContext, total=False):
|
||||
redirect_uri: str
|
||||
|
||||
|
||||
AuthFlowResult = FlowResult[AuthFlowContext, tuple[str, str]]
|
||||
class AuthFlowResult(FlowResult[AuthFlowContext, tuple[str, str]], total=False):
|
||||
"""Typed result dict for auth flow."""
|
||||
|
||||
result: Credentials # Only present if type is CREATE_ENTRY
|
||||
|
||||
|
||||
@attr.s(slots=True)
|
||||
|
@ -268,7 +268,7 @@ class LoginFlowBaseView(HomeAssistantView):
|
||||
result.pop("data")
|
||||
result.pop("context")
|
||||
|
||||
result_obj: Credentials = result.pop("result")
|
||||
result_obj = result.pop("result")
|
||||
|
||||
# Result can be None if credential was never linked to a user before.
|
||||
user = await hass.auth.async_get_user_by_credentials(result_obj)
|
||||
@ -281,7 +281,8 @@ class LoginFlowBaseView(HomeAssistantView):
|
||||
)
|
||||
|
||||
process_success_login(request)
|
||||
result["result"] = self._store_result(client_id, result_obj)
|
||||
# We overwrite the Credentials object with the string code to retrieve it.
|
||||
result["result"] = self._store_result(client_id, result_obj) # type: ignore[typeddict-item]
|
||||
|
||||
return self.json(result)
|
||||
|
||||
|
@ -146,8 +146,9 @@ def _prepare_config_flow_result_json(
|
||||
return prepare_result_json(result)
|
||||
|
||||
data = result.copy()
|
||||
entry: config_entries.ConfigEntry = data["result"]
|
||||
data["result"] = entry.as_json_fragment
|
||||
entry: config_entries.ConfigEntry = data["result"] # type: ignore[typeddict-item]
|
||||
# We overwrite the ConfigEntry object with its json representation.
|
||||
data["result"] = entry.as_json_fragment # type: ignore[typeddict-unknown-key]
|
||||
data.pop("data")
|
||||
data.pop("context")
|
||||
return data
|
||||
|
@ -89,8 +89,6 @@ class RepairsFlowManager(data_entry_flow.FlowManager):
|
||||
"""
|
||||
if result.get("type") != data_entry_flow.FlowResultType.ABORT:
|
||||
ir.async_delete_issue(self.hass, flow.handler, flow.init_data["issue_id"])
|
||||
if "result" not in result:
|
||||
result["result"] = None
|
||||
return result
|
||||
|
||||
|
||||
|
@ -298,8 +298,10 @@ class ConfigFlowContext(FlowContext, total=False):
|
||||
class ConfigFlowResult(FlowResult[ConfigFlowContext, str], total=False):
|
||||
"""Typed result dict for config flow."""
|
||||
|
||||
# Extra keys, only present if type is CREATE_ENTRY
|
||||
minor_version: int
|
||||
options: Mapping[str, Any]
|
||||
result: ConfigEntry
|
||||
subentries: Iterable[ConfigSubentryData]
|
||||
version: int
|
||||
|
||||
@ -3345,7 +3347,6 @@ class ConfigSubentryFlowManager(
|
||||
),
|
||||
)
|
||||
|
||||
result["result"] = True
|
||||
return result
|
||||
|
||||
|
||||
@ -3508,7 +3509,6 @@ class OptionsFlowManager(
|
||||
):
|
||||
self.hass.config_entries.async_schedule_reload(entry.entry_id)
|
||||
|
||||
result["result"] = True
|
||||
return result
|
||||
|
||||
async def _async_setup_preview(
|
||||
|
@ -142,7 +142,6 @@ class FlowResult(TypedDict, Generic[_FlowContextT, _HandlerT], total=False):
|
||||
progress_task: asyncio.Task[Any] | None
|
||||
reason: str
|
||||
required: bool
|
||||
result: Any
|
||||
step_id: str
|
||||
title: str
|
||||
translation_domain: str
|
||||
|
@ -35,7 +35,7 @@ class _BaseFlowManagerView(HomeAssistantView, Generic[_FlowManagerT]):
|
||||
"""Convert result to JSON."""
|
||||
if result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY:
|
||||
data = result.copy()
|
||||
data.pop("result")
|
||||
assert "result" not in result
|
||||
data.pop("data")
|
||||
data.pop("context")
|
||||
return data
|
||||
|
@ -236,7 +236,6 @@ async def test_legacy_subscription_repair_flow_timeout(
|
||||
"handler": "cloud",
|
||||
"reason": "operation_took_too_long",
|
||||
"description_placeholders": None,
|
||||
"result": None,
|
||||
}
|
||||
|
||||
assert issue_registry.async_get_issue(
|
||||
|
@ -15,7 +15,6 @@
|
||||
# ---
|
||||
# name: test_options[create_entry]
|
||||
FlowResultSnapshot({
|
||||
'result': True,
|
||||
'type': <FlowResultType.CREATE_ENTRY: 'create_entry'>,
|
||||
})
|
||||
# ---
|
||||
|
@ -39,7 +39,6 @@
|
||||
# ---
|
||||
# name: test_options[create_entry]
|
||||
FlowResultSnapshot({
|
||||
'result': True,
|
||||
'type': <FlowResultType.CREATE_ENTRY: 'create_entry'>,
|
||||
})
|
||||
# ---
|
||||
|
@ -471,7 +471,6 @@ async def test_mount_failed_repair_flow_error(
|
||||
"flow_id": flow_id,
|
||||
"handler": "hassio",
|
||||
"reason": "apply_suggestion_fail",
|
||||
"result": None,
|
||||
"description_placeholders": None,
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,6 @@ async def test_options_flow(
|
||||
)
|
||||
|
||||
assert create_result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert create_result["result"] is True
|
||||
|
||||
assert config_entry.data == {
|
||||
"firmware": "ezsp",
|
||||
|
@ -406,7 +406,6 @@ async def test_firmware_options_flow(
|
||||
)
|
||||
|
||||
assert create_result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert create_result["result"] is True
|
||||
|
||||
assert config_entry.data == {
|
||||
"firmware": fw_type.value,
|
||||
|
@ -110,7 +110,6 @@ async def test_options_reconfigure(
|
||||
CONF_CANDLE_LIGHT_MINUTES: DEFAULT_CANDLE_LIGHT + 1,
|
||||
},
|
||||
)
|
||||
assert result["result"]
|
||||
|
||||
# The value of the "upcoming_shabbat_candle_lighting" sensor should be the new value
|
||||
assert config_entry.options[CONF_CANDLE_LIGHT_MINUTES] == DEFAULT_CANDLE_LIGHT + 1
|
||||
|
@ -599,7 +599,6 @@ async def test_fix_issue_aborted(
|
||||
"handler": "fake_integration",
|
||||
"reason": "not_given",
|
||||
"description_placeholders": None,
|
||||
"result": None,
|
||||
}
|
||||
|
||||
await ws_client.send_json({"id": 4, "type": "repairs/list_issues"})
|
||||
|
Loading…
x
Reference in New Issue
Block a user