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

_transform_typeddict() — anthropic-sdk-python Function Reference

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

Function python AnthropicClient SyncAPI calls 4 called by 1

Entity Profile

Dependency Diagram

graph TD
  73674319_0076_f928_202c_b195fd052f6b["_transform_typeddict()"]
  17ea9c01_2df6_304d_71e2_31af17ed7395["_transform.py"]
  73674319_0076_f928_202c_b195fd052f6b -->|defined in| 17ea9c01_2df6_304d_71e2_31af17ed7395
  76cf4787_3c42_ee68_9967_3160c7a1aa0d["_transform_recursive()"]
  76cf4787_3c42_ee68_9967_3160c7a1aa0d -->|calls| 73674319_0076_f928_202c_b195fd052f6b
  00c9ace9_7d04_60d7_22f8_89998c663c4b["get_type_hints()"]
  73674319_0076_f928_202c_b195fd052f6b -->|calls| 00c9ace9_7d04_60d7_22f8_89998c663c4b
  134c332e_654b_985e_839c_e13698f1b9e7["is_given()"]
  73674319_0076_f928_202c_b195fd052f6b -->|calls| 134c332e_654b_985e_839c_e13698f1b9e7
  7dd9f3f8_e9d3_eb28_5171_d0dd7a1780c9["_maybe_transform_key()"]
  73674319_0076_f928_202c_b195fd052f6b -->|calls| 7dd9f3f8_e9d3_eb28_5171_d0dd7a1780c9
  76cf4787_3c42_ee68_9967_3160c7a1aa0d["_transform_recursive()"]
  73674319_0076_f928_202c_b195fd052f6b -->|calls| 76cf4787_3c42_ee68_9967_3160c7a1aa0d
  style 73674319_0076_f928_202c_b195fd052f6b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/_utils/_transform.py lines 263–281

def _transform_typeddict(
    data: Mapping[str, object],
    expected_type: type,
) -> Mapping[str, object]:
    result: dict[str, object] = {}
    annotations = get_type_hints(expected_type, include_extras=True)
    for key, value in data.items():
        if not is_given(value):
            # we don't need to include omitted values here as they'll
            # be stripped out before the request is sent anyway
            continue

        type_ = annotations.get(key)
        if type_ is None:
            # we do not have a type annotation for this field, leave it as is
            result[key] = value
        else:
            result[_maybe_transform_key(key, type_)] = _transform_recursive(value, annotation=type_)
    return result

Subdomains

Frequently Asked Questions

What does _transform_typeddict() do?
_transform_typeddict() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_utils/_transform.py.
Where is _transform_typeddict() defined?
_transform_typeddict() is defined in src/anthropic/_utils/_transform.py at line 263.
What does _transform_typeddict() call?
_transform_typeddict() calls 4 function(s): _maybe_transform_key, _transform_recursive, get_type_hints, is_given.
What calls _transform_typeddict()?
_transform_typeddict() is called by 1 function(s): _transform_recursive.

Analyze Your Own Codebase

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

Try Supermodel Free