Skip to content

Feature Request: Update BaseModelTransform to use TypeAdapter #391

Description

@vmlopezr

Pydantic's TypeAdapter has dump_python/dump_json (to serialize) and validate_python/validate_json to validate the annotations.

At the moment the BaseModelTransform/SerializationTransform only supports annotating BaseModel or list[BaseModel]. If we switch these to use TypeAdapter we could probably directly use TypeAdapter(annotation).validate_python (or validate_json) to also support validating/serializing annotations like dict[str, BaseModel], or more complicated types.

Thoughts on this suggestion? Happy to give it a attempt at a PR depending on feedback

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions