test_list_optional_items_nested_model() — anthropic-sdk-python Function Reference
Architecture documentation for the test_list_optional_items_nested_model() function in test_models.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 5247699a_6e1a_e08c_5435_2af4ff0d3d3f["test_list_optional_items_nested_model()"] 7872e60b_4210_5600_119f_c5d08c52091e["test_models.py"] 5247699a_6e1a_e08c_5435_2af4ff0d3d3f -->|defined in| 7872e60b_4210_5600_119f_c5d08c52091e style 5247699a_6e1a_e08c_5435_2af4ff0d3d3f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_models.py lines 95–112
def test_list_optional_items_nested_model() -> None:
class NestedModel(BaseModel):
nested: List[Optional[BasicModel]]
m = NestedModel.construct(nested=[None, {"foo": "bar"}])
assert m.nested is not None
assert isinstance(m.nested, list)
assert len(m.nested) == 2
assert m.nested[0] is None
assert m.nested[1] is not None
assert m.nested[1].foo == "bar"
# mismatched types
m3 = NestedModel.construct(nested="foo")
assert cast(Any, m3.nested) == "foo"
m4 = NestedModel.construct(nested=[False])
assert cast(Any, m4.nested) == [False]
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_list_optional_items_nested_model() do?
test_list_optional_items_nested_model() is a function in the anthropic-sdk-python codebase, defined in tests/test_models.py.
Where is test_list_optional_items_nested_model() defined?
test_list_optional_items_nested_model() is defined in tests/test_models.py at line 95.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free