mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
25b5d98030
* support postponed annotations in python 3.7 * support for full ForwardRef * tweak update_forward_refs * better ForwardRef resolution * remove debug, fix linting * fix comments * docs and history
16 lines
266 B
Python
16 lines
266 B
Python
from typing import ForwardRef
|
|
from pydantic import BaseModel
|
|
|
|
Foo = ForwardRef('Foo')
|
|
|
|
class Foo(BaseModel):
|
|
a: int = 123
|
|
b: Foo = None
|
|
|
|
Foo.update_forward_refs()
|
|
|
|
print(Foo())
|
|
#> Foo a=123 b=None
|
|
print(Foo(b={'a': '321'}))
|
|
#> Foo a=123 b=<Foo a=321 b=None>
|