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,
)
| 90 | |
| 91 | class="cm"># Wrapper over _transform_recursive providing fake types |
| 92 | def transform( |
| 93 | data: _T, |
| 94 | expected_type: object, |
| 95 | ) -> _T: |
| 96 | class="st">"""Transform dictionaries based off of type information from the given type, for example: |
| 97 | |
| 98 | ```py |
| 99 | class Params(TypedDict, total=False): |
| 100 | card_id: Required[Annotated[str, PropertyInfo(alias=class="st">"cardID")]] |
| 101 | |
| 102 | |
| 103 | transformed = transform({class="st">"card_id": class="st">"<my card ID>"}, Params) |
| 104 | class="cm"># {class="st">'cardID': class="st">'<my card ID>'} |
| 105 | ``` |
| 106 | |
| 107 | Any keys / data that does not have type information given will be included as is. |
| 108 | |
| 109 | It should be noted that the transformations that this function does are not represented in the type system. |
| 110 | class="st">""" |
| 111 | transformed = _transform_recursive(data, annotation=cast(type, expected_type)) |
| 112 | return cast(_T, transformed) |
| 113 | |
| 114 | |
| 115 | @lru_cache(maxsize=8096) |
no test coverage detected