nemo_microservices._utils._transform#
Module Contents#
Classes#
Metadata class to be used in Annotated types to provide information about a given type. |
Functions#
Wrapper over |
|
Transform dictionaries based off of type information from the given type, for example: |
|
Wrapper over |
|
Transform dictionaries based off of type information from the given type, for example: |
Data#
API#
- nemo_microservices._utils._transform.PropertyFormat#
None
- class nemo_microservices._utils._transform.PropertyInfo(
- *,
- alias: str | None = None,
- format: nemo_microservices._utils._transform.PropertyFormat | None = None,
- format_template: str | None = None,
- discriminator: str | None = None,
Metadata class to be used in Annotated types to provide information about a given type.
For example:
class MyParams(TypedDict): account_holder_name: Annotated[str, PropertyInfo(alias=’accountHolderName’)]
This means that {‘account_holder_name’: ‘Robert’} will be transformed to {‘accountHolderName’: ‘Robert’} before being sent to the API.
Initialization
- alias: str | None#
None
- discriminator: str | None#
None
- format: nemo_microservices._utils._transform.PropertyFormat | None#
None
- format_template: str | None#
None
- async nemo_microservices._utils._transform.async_maybe_transform(
- data: object,
- expected_type: object,
Wrapper over
async_transform()that allowsNoneto be passed.See
async_transform()for more details.
- async nemo_microservices._utils._transform.async_transform(
- data: nemo_microservices._utils._transform._T,
- expected_type: object,
Transform dictionaries based off of type information from the given type, for example:
class Params(TypedDict, total=False): card_id: Required[Annotated[str, PropertyInfo(alias="cardID")]] transformed = transform({"card_id": "<my card ID>"}, Params) # {'cardID': '<my card ID>'}
Any keys / data that does not have type information given will be included as is.
It should be noted that the transformations that this function does are not represented in the type system.
- nemo_microservices._utils._transform.get_type_hints(
- obj: Any,
- globalns: dict[str, Any] | None = None,
- localns: Mapping[str, Any] | None = None,
- include_extras: bool = False,
- nemo_microservices._utils._transform.maybe_transform(data: object, expected_type: object) Any | None#
Wrapper over
transform()that allowsNoneto be passed.See
transform()for more details.
- nemo_microservices._utils._transform.transform(
- data: nemo_microservices._utils._transform._T,
- expected_type: object,
Transform dictionaries based off of type information from the given type, for example:
class Params(TypedDict, total=False): card_id: Required[Annotated[str, PropertyInfo(alias="cardID")]] transformed = transform({"card_id": "<my card ID>"}, Params) # {'cardID': '<my card ID>'}
Any keys / data that does not have type information given will be included as is.
It should be noted that the transformations that this function does are not represented in the type system.