mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Rewrite flow handler to flow result conversion as a list comp (#118269)
This commit is contained in:
parent
6f248acfd5
commit
a5644c8ddb
@ -608,19 +608,22 @@ class FlowManager(abc.ABC, Generic[_FlowResultT, _HandlerT]):
|
|||||||
include_uninitialized: bool,
|
include_uninitialized: bool,
|
||||||
) -> list[_FlowResultT]:
|
) -> list[_FlowResultT]:
|
||||||
"""Convert a list of FlowHandler to a partial FlowResult that can be serialized."""
|
"""Convert a list of FlowHandler to a partial FlowResult that can be serialized."""
|
||||||
results = []
|
return [
|
||||||
for flow in flows:
|
self._flow_result(
|
||||||
if not include_uninitialized and flow.cur_step is None:
|
flow_id=flow.flow_id,
|
||||||
continue
|
handler=flow.handler,
|
||||||
result = self._flow_result(
|
context=flow.context,
|
||||||
|
step_id=flow.cur_step["step_id"],
|
||||||
|
)
|
||||||
|
if flow.cur_step
|
||||||
|
else self._flow_result(
|
||||||
flow_id=flow.flow_id,
|
flow_id=flow.flow_id,
|
||||||
handler=flow.handler,
|
handler=flow.handler,
|
||||||
context=flow.context,
|
context=flow.context,
|
||||||
)
|
)
|
||||||
if flow.cur_step:
|
for flow in flows
|
||||||
result["step_id"] = flow.cur_step["step_id"]
|
if include_uninitialized or flow.cur_step is not None
|
||||||
results.append(result)
|
]
|
||||||
return results
|
|
||||||
|
|
||||||
|
|
||||||
class FlowHandler(Generic[_FlowResultT, _HandlerT]):
|
class FlowHandler(Generic[_FlowResultT, _HandlerT]):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user