Home / Function/ test_discriminated_unions_unknown_variant() — anthropic-sdk-python Function Reference

test_discriminated_unions_unknown_variant() — anthropic-sdk-python Function Reference

Architecture documentation for the test_discriminated_unions_unknown_variant() function in test_models.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  2f717cc0_469e_345b_3c39_5309e1eca752["test_discriminated_unions_unknown_variant()"]
  7872e60b_4210_5600_119f_c5d08c52091e["test_models.py"]
  2f717cc0_469e_345b_3c39_5309e1eca752 -->|defined in| 7872e60b_4210_5600_119f_c5d08c52091e
  style 2f717cc0_469e_345b_3c39_5309e1eca752 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_models.py lines 690–710

def test_discriminated_unions_unknown_variant() -> None:
    class A(BaseModel):
        type: Literal["a"]

        data: str

    class B(BaseModel):
        type: Literal["b"]

        data: int

    m = construct_type(
        value={"type": "c", "data": None, "new_thing": "bar"},
        type_=cast(Any, Annotated[Union[A, B], PropertyInfo(discriminator="type")]),
    )

    # just chooses the first variant
    assert isinstance(m, A)
    assert m.type == "c"  # type: ignore[comparison-overlap]
    assert m.data == None  # type: ignore[unreachable]
    assert m.new_thing == "bar"

Subdomains

Frequently Asked Questions

What does test_discriminated_unions_unknown_variant() do?
test_discriminated_unions_unknown_variant() is a function in the anthropic-sdk-python codebase, defined in tests/test_models.py.
Where is test_discriminated_unions_unknown_variant() defined?
test_discriminated_unions_unknown_variant() is defined in tests/test_models.py at line 690.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free