MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / async_transform

Function async_transform

src/anthropic/_utils/_transform.py:296–316  ·  view source on GitHub ↗

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": " "}, Params) # {'cardID': '<my

(
    data: _T,
    expected_type: object,
)

Source from the content-addressed store, hash-verified

294
295
296async def async_transform(
297 data: _T,
298 expected_type: object,
299) -> _T:
300 """Transform dictionaries based off of type information from the given type, for example:
301
302 ```py
303 class Params(TypedDict, total=False):
304 card_id: Required[Annotated[str, PropertyInfo(alias="cardID")]]
305
306
307 transformed = transform({"card_id": "<my card ID>"}, Params)
308 # {'cardID': '<my card ID>'}
309 ```
310
311 Any keys / data that does not have type information given will be included as is.
312
313 It should be noted that the transformations that this function does are not represented in the type system.
314 """
315 transformed = await _async_transform_recursive(data, annotation=cast(type, expected_type))
316 return cast(_T, transformed)
317
318
319async def _async_transform_recursive(

Callers 1

async_maybe_transformFunction · 0.85

Calls 1

Tested by

no test coverage detected