Skip to content

Remove use of __root__ in Pydantic models #40

Description

@pederhan

Pydantic V2 removes support for __root__ in models. The Pre-release blog post provides 2 different ways to create models with "root" fields.

The easiest replacement seems to be AnalyzedType. This uses the new Pydantic V2 type that allows for creating arbitrary types from generic annotations.

Another, more complicated approach, if custom behavior is required, is to provide custom model validators and serializers, as demonstrated in the Pydantic test suite. This seems to provide more flexibility, but adds a lot of boilerplate code and it's unclear if we actually need this flexibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions