Skip to content

Commit 3dd8732

Browse files
committed
Python: test(core): narrow the optional props before subscripting in the detach test
The four test type checkers all rejected subscripting Content's optional additional_properties/annotations directly. Bind and assert them first. Signed-off-by: Yufeng He <[email protected]>
1 parent 376748d commit 3dd8732

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎python/packages/core/tests/core/test_types.py‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,10 +2653,16 @@ def test_coalesce_detaches_run_head_nested_values() -> None:
26532653
)
26542654
contents = [head, Content.from_text("t")]
26552655
_coalesce_text_content(contents, "text")
2656-
head.additional_properties["k"]["nested"] = 99
2657-
head.annotations[0]["url"] = "https://mutated"
2658-
assert contents[0].additional_properties["k"]["nested"] == 1
2659-
assert contents[0].annotations[0]["url"] == "https://a"
2656+
props = head.additional_properties
2657+
annotations = head.annotations
2658+
assert props is not None and annotations is not None
2659+
props["k"]["nested"] = 99
2660+
annotations[0]["url"] = "https://mutated"
2661+
folded_props = contents[0].additional_properties
2662+
folded_annotations = contents[0].annotations
2663+
assert folded_props is not None and folded_annotations is not None
2664+
assert folded_props["k"]["nested"] == 1
2665+
assert folded_annotations[0]["url"] == "https://a"
26602666

26612667

26622668
@pytest.mark.parametrize("type_str", ["text", "text_reasoning"])

0 commit comments

Comments
 (0)