Skip to content

Support typing.annotated #558

Description

@Leon0824

Feature request

Context

This works:

class ClassicMemberItem(Model):
    id2: str = Field(default_factory=lambda: 'm1id')

m1 = ClassicMemberItem() # id=ObjectId('6a13e2017c4eef33beb24616') id2='m1id'

This does not work:

from typing import Annotated

class ClassicMemberItem2(Model):
    id2: Annotated[str, Field(default_factory=lambda: 'm2id')]

m2 = ClassicMemberItem2() # ValidationError: 1 validation error for ClassicMemberItem2

However, typing.annotated is supported by Pydantic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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