Home / File/ test_transform.py — anthropic-sdk-python Source File

test_transform.py — anthropic-sdk-python Source File

Architecture documentation for test_transform.py, a python file in the anthropic-sdk-python codebase. 10 imports, 0 dependents.

File python AnthropicClient Authentication 10 imports 29 functions 29 classes

Entity Profile

Dependency Diagram

graph LR
  6d065906_49ba_5188_2c4a_08d599bd18f8["test_transform.py"]
  3ee9df07_3d82_3549_bc64_a6db4e026506["io"]
  6d065906_49ba_5188_2c4a_08d599bd18f8 --> 3ee9df07_3d82_3549_bc64_a6db4e026506
  525f4270_cbfe_512c_fbe4_e6566e0cdf13["pathlib"]
  6d065906_49ba_5188_2c4a_08d599bd18f8 --> 525f4270_cbfe_512c_fbe4_e6566e0cdf13
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  6d065906_49ba_5188_2c4a_08d599bd18f8 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  7e1d14c5_475e_409c_7c4e_1274f9d40aa9["datetime"]
  6d065906_49ba_5188_2c4a_08d599bd18f8 --> 7e1d14c5_475e_409c_7c4e_1274f9d40aa9
  37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"]
  6d065906_49ba_5188_2c4a_08d599bd18f8 --> 37c05070_ca59_d596_7250_de9d1939227f
  cde8421b_93c7_41e4_d69d_2a3f1bade2f2["pytest"]
  6d065906_49ba_5188_2c4a_08d599bd18f8 --> cde8421b_93c7_41e4_d69d_2a3f1bade2f2
  01a140e6_b92b_0f78_5c02_ede12a95cdde["anthropic._types"]
  6d065906_49ba_5188_2c4a_08d599bd18f8 --> 01a140e6_b92b_0f78_5c02_ede12a95cdde
  d1009234_f799_7c53_7892_4262523206dd["anthropic._utils"]
  6d065906_49ba_5188_2c4a_08d599bd18f8 --> d1009234_f799_7c53_7892_4262523206dd
  42bc4048_b76c_4d27_9cbe_884618df8c52["anthropic._compat"]
  6d065906_49ba_5188_2c4a_08d599bd18f8 --> 42bc4048_b76c_4d27_9cbe_884618df8c52
  7d132c4d_8665_7d6c_3d3d_3b1d1f22b9eb["anthropic._models"]
  6d065906_49ba_5188_2c4a_08d599bd18f8 --> 7d132c4d_8665_7d6c_3d3d_3b1d1f22b9eb
  style 6d065906_49ba_5188_2c4a_08d599bd18f8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import io
import pathlib
from typing import Any, Dict, List, Union, TypeVar, Iterable, Optional, cast
from datetime import date, datetime
from typing_extensions import Required, Annotated, TypedDict

import pytest

from anthropic._types import Base64FileInput, omit, not_given
from anthropic._utils import (
    PropertyInfo,
    transform as _transform,
    parse_datetime,
    async_transform as _async_transform,
)
from anthropic._compat import PYDANTIC_V1
from anthropic._models import BaseModel

_T = TypeVar("_T")

SAMPLE_FILE_PATH = pathlib.Path(__file__).parent.joinpath("sample_file.txt")


async def transform(
    data: _T,
    expected_type: object,
    use_async: bool,
) -> _T:
    if use_async:
        return await _async_transform(data, expected_type=expected_type)

    return _transform(data, expected_type=expected_type)


parametrize = pytest.mark.parametrize("use_async", [False, True], ids=["sync", "async"])


class Foo1(TypedDict):
    foo_bar: Annotated[str, PropertyInfo(alias="fooBar")]


@parametrize
@pytest.mark.asyncio
async def test_top_level_alias(use_async: bool) -> None:
    assert await transform({"foo_bar": "hello"}, expected_type=Foo1, use_async=use_async) == {"fooBar": "hello"}


class Foo2(TypedDict):
    bar: Bar2


class Bar2(TypedDict):
    this_thing: Annotated[int, PropertyInfo(alias="this__thing")]
    baz: Annotated[Baz2, PropertyInfo(alias="Baz")]


class Baz2(TypedDict):
    my_baz: Annotated[str, PropertyInfo(alias="myBaz")]
// ... (401 more lines)

Subdomains

Dependencies

  • anthropic._compat
  • anthropic._models
  • anthropic._types
  • anthropic._utils
  • datetime
  • io
  • pathlib
  • pytest
  • typing
  • typing_extensions

Frequently Asked Questions

What does test_transform.py do?
test_transform.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, Authentication subdomain.
What functions are defined in test_transform.py?
test_transform.py defines 29 function(s): test_base64_file_input, test_datetime_custom_format, test_datetime_with_alias, test_dictionary_items, test_ignores_invalid_input, test_includes_unknown_keys, test_iso8601_format, test_iterable_of_dictionaries, test_iterable_union_str, test_list_of_typeddict, and 19 more.
What does test_transform.py depend on?
test_transform.py imports 10 module(s): anthropic._compat, anthropic._models, anthropic._types, anthropic._utils, datetime, io, pathlib, pytest, and 2 more.
Where is test_transform.py in the architecture?
test_transform.py is located at tests/test_transform.py (domain: AnthropicClient, subdomain: Authentication, directory: tests).

Analyze Your Own Codebase

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

Try Supermodel Free