style: format workflow output binding slice

This commit is contained in:
lda
2026-07-26 21:35:37 +07:00 Verified
parent b65f11e2da
commit 0f11773611
4 changed files with 23 additions and 35 deletions
+2 -6
View File
@@ -620,8 +620,7 @@ class WorkflowDraftAuthoringApi:
)
if not schema_path_exists(projected, target_parts):
raise ValueError(
f"bindings[{index}].target {str(binding.target)!r} "
"is not declared"
f"bindings[{index}].target {str(binding.target)!r} is not declared"
)
validate_json_value_at_schema_path(
schema=projected,
@@ -632,10 +631,7 @@ class WorkflowDraftAuthoringApi:
)
payload = [binding.model_dump(mode="json") for binding in bindings]
if (
workspace.draft.get("output", []) == payload
and projected == output_schema
):
if workspace.draft.get("output", []) == payload and projected == output_schema:
return summarize_draft_workspace(workspace)
patch: list[dict[str, Any]] = []
+18 -20
View File
@@ -3834,12 +3834,12 @@ async def test_set_workflow_output_bindings_projects_nested_paths_and_literals(
{"path": "state.report.title", "target": "audit.title"},
{"value": "markdown", "target": "format"},
]
assert inspected["draft"]["output_schema"]["properties"]["report"][
"properties"
]["title"] == {"type": "string"}
assert inspected["draft"]["output_schema"]["properties"]["audit"][
"properties"
]["title"] == {"type": "string"}
assert inspected["draft"]["output_schema"]["properties"]["report"]["properties"][
"title"
] == {"type": "string"}
assert inspected["draft"]["output_schema"]["properties"]["audit"]["properties"][
"title"
] == {"type": "string"}
cleared = await authoring.set_workflow_output_bindings(
workspace_id="report",
@@ -3894,9 +3894,9 @@ async def test_set_workflow_output_bindings_projects_input_and_whole_state(
output_schema = inspected["draft"]["output_schema"]["properties"]
assert output_schema["input_title"] == {"type": "string"}
assert output_schema["snapshot"]["properties"]["report"]["properties"][
"title"
] == {"type": "string"}
assert output_schema["snapshot"]["properties"]["report"]["properties"]["title"] == {
"type": "string"
}
@pytest.mark.asyncio
@@ -4110,14 +4110,14 @@ async def test_set_workflow_output_bindings_validates_root_literal_complete_sche
r"bindings\[0\]\.path 'state\.missing' is not declared",
),
(
[
InputPathBinding(
path=GraphSourcePath.state("report"),
target=LocalPath.of("format"),
)
],
r"bindings\[0\]\.target 'format' cannot receive source "
r"'state\.report'",
[
InputPathBinding(
path=GraphSourcePath.state("report"),
target=LocalPath.of("format"),
)
],
r"bindings\[0\]\.target 'format' cannot receive source "
r"'state\.report'",
),
(
[
@@ -4274,9 +4274,7 @@ async def test_cleared_workflow_output_bindings_preserve_state_fallback(
first = await authoring.set_workflow_output_bindings(
workspace_id="report",
revision=1,
bindings=[
InputValueBinding(target=LocalPath.of("echoed"), value="explicit")
],
bindings=[InputValueBinding(target=LocalPath.of("echoed"), value="explicit")],
)
await authoring.set_workflow_output_bindings(
workspace_id="report",
+2 -6
View File
@@ -153,9 +153,7 @@ async def test_registered_workflow_output_bindings_tool_preserves_union_order(
def __init__(self) -> None:
self.calls: list[dict[str, Any]] = []
async def set_workflow_output_bindings(
self, **kwargs: Any
) -> dict[str, Any]:
async def set_workflow_output_bindings(self, **kwargs: Any) -> dict[str, Any]:
self.calls.append(kwargs)
return {
"workspace_id": kwargs["workspace_id"],
@@ -204,9 +202,7 @@ async def test_registered_workflow_output_bindings_tool_preserves_union_order(
call = recorder.calls[0]
assert isinstance(call["bindings"][0], InputPathBinding)
assert isinstance(call["bindings"][1], InputValueBinding)
assert [
binding.model_dump(mode="json") for binding in call["bindings"]
] == [
assert [binding.model_dump(mode="json") for binding in call["bindings"]] == [
{"path": "state.report.title", "target": "report.title"},
{"value": "markdown", "target": "format"},
]
+1 -3
View File
@@ -347,9 +347,7 @@ def test_set_workflow_output_bindings_request_preserves_union_order() -> None:
assert isinstance(request.bindings[0], InputPathBinding)
assert isinstance(request.bindings[1], InputValueBinding)
assert [
binding.model_dump(mode="json") for binding in request.bindings
] == [
assert [binding.model_dump(mode="json") for binding in request.bindings] == [
{"path": "state.report.title", "target": "report.title"},
{"value": "markdown", "target": "format"},
]