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