mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
15 lines
335 B
Python
15 lines
335 B
Python
from __future__ import annotations
|
|
from pydantic import BaseModel
|
|
|
|
class Foo(BaseModel):
|
|
a: int = 123
|
|
#: The sibling of `Foo` is referenced directly by type
|
|
sibling: Foo = None
|
|
|
|
Foo.update_forward_refs()
|
|
|
|
print(Foo())
|
|
#> Foo a=123 sibling=None
|
|
print(Foo(sibling={'a': '321'}))
|
|
#> Foo a=123 sibling=<Foo a=321 sibling=None>
|