MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / async_transform

Function async_transform

src/opencode_ai/_utils/_transform.py:291–311  ·  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

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

Callers 1

async_maybe_transformFunction · 0.85

Calls 1

Tested by

no test coverage detected