mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
b742c6f527
* Infer root type from Annotated * Extract Field from Annotated * Add changelog * Extend existing get_args/get_origin * Fix Annotated on py3.6 without typing-extensions * Handle Ellipsis default * Fix field reuse after FieldInfo.default mutation * Fix ci
14 lines
312 B
Python
14 lines
312 B
Python
from uuid import uuid4
|
|
|
|
try:
|
|
from typing import Annotated
|
|
except ImportError:
|
|
from typing_extensions import Annotated
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class Foo(BaseModel):
|
|
id: Annotated[str, Field(default_factory=lambda: uuid4().hex)]
|
|
name: Annotated[str, Field(max_length=256)] = 'Bar'
|