DevOps Buzz
Search…
Bash / Shell
Bitbucket
Distros
Elasticsearch
General
Guidelines / Standards
microk8s
Prometheus
RabbitMQ
VirtualBox
Pydantic
Python data serialization tips

update_forward_refs

1
from __future__ import annotations
2
from typing import List
3
from pydantic import BaseModel
4
5
6
class UserAlone(BaseModel):
7
id: int = None
8
name: str
9
10
class Config:
11
orm_mode = True
12
13
class User(UserAlone):
14
roles: List['RoleAlone']= []
15
16
class RoleAlone(BaseModel):
17
id: int = None
18
name: str
19
20
class Config:
21
orm_mode = True
22
23
User.update_forward_refs()
24
25
class Role(RoleAlone):
26
users: List[UserAlone]
Copied!
Copy link