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

transform() — anthropic-sdk-python Function Reference

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

Function python AnthropicClient AsyncAPI calls 1 called by 2

Entity Profile

Dependency Diagram

graph TD
  d6615324_bb52_2f02_df89_851d5be298c2["transform()"]
  17ea9c01_2df6_304d_71e2_31af17ed7395["_transform.py"]
  d6615324_bb52_2f02_df89_851d5be298c2 -->|defined in| 17ea9c01_2df6_304d_71e2_31af17ed7395
  8df85f7c_e833_009b_6b6d_7a20afe4c497["maybe_transform()"]
  8df85f7c_e833_009b_6b6d_7a20afe4c497 -->|calls| d6615324_bb52_2f02_df89_851d5be298c2
  7450322a_5cbb_6034_d7f1_29c32ca76e4b["async_transform()"]
  7450322a_5cbb_6034_d7f1_29c32ca76e4b -->|calls| d6615324_bb52_2f02_df89_851d5be298c2
  76cf4787_3c42_ee68_9967_3160c7a1aa0d["_transform_recursive()"]
  d6615324_bb52_2f02_df89_851d5be298c2 -->|calls| 76cf4787_3c42_ee68_9967_3160c7a1aa0d
  style d6615324_bb52_2f02_df89_851d5be298c2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/_utils/_transform.py lines 92–112

def transform(
    data: _T,
    expected_type: object,
) -> _T:
    """Transform dictionaries based off of type information from the given type, for example:

    ```py
    class Params(TypedDict, total=False):
        card_id: Required[Annotated[str, PropertyInfo(alias="cardID")]]


    transformed = transform({"card_id": "<my card ID>"}, Params)
    # {'cardID': '<my card ID>'}
    ```

    Any keys / data that does not have type information given will be included as is.

    It should be noted that the transformations that this function does are not represented in the type system.
    """
    transformed = _transform_recursive(data, annotation=cast(type, expected_type))
    return cast(_T, transformed)

Subdomains

Frequently Asked Questions

What does transform() do?
transform() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_utils/_transform.py.
Where is transform() defined?
transform() is defined in src/anthropic/_utils/_transform.py at line 92.
What does transform() call?
transform() calls 1 function(s): _transform_recursive.
What calls transform()?
transform() is called by 2 function(s): async_transform, maybe_transform.

Analyze Your Own Codebase

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

Try Supermodel Free