Skip to content

Latest commit

 

History

History
56 lines (36 loc) · 1.61 KB

README.md

File metadata and controls

56 lines (36 loc) · 1.61 KB

pyruicore

Build Status   Coverage Status   codebeat badge   python3.8   issues stars   license

  • This package is used to load python dict data to python class.

Usage

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"},
    ]
}
"""

Maintainers

@ruicore

Contributing

PRs are accepted, this is first workout version, may have many bugs, so welcome to point out bugs and fix it.

License

MIT © 2020 ruicore