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,
)
| 294 | |
| 295 | |
| 296 | async 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 | |
| 319 | async def _async_transform_recursive( |
no test coverage detected