MCPcopy
hub / github.com/openai/openai-python / async_transform

Function async_transform

src/openai/_utils/_transform.py:297–317  ·  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": "<my card ID>"}, Params) # {'cardID': '<my

(
    data: _T,
    expected_type: object,
)

Source from the content-addressed store, hash-verified

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

Callers 1

async_maybe_transformFunction · 0.85

Calls 1

Tested by

no test coverage detected