- This package is used to load python dict data to python class.
- pip install pyruicore -i https://pypi.org/simple
from pyruicore import BaseModel, Field
class Department(BaseModel):
name: str
address: str
class User(BaseModel):
age: int = Field(default_factory=lambda: 1)
departs: List[Department]
user = User(
departs=[
{"name": "de1", "address": "address1"},
Department(name="2", address="address2"),
]
)
user_dict = user.dict()
"""
user_dict = {
"age": 1,
"departs": [
{"name": "de1", "address": "address1"},
{"name": "2", "address": "address2"},
]
}
"""
PRs are accepted, this is first workout version, may have many bugs, so welcome to point out bugs and fix it.
MIT © 2020 ruicore