Skip to main content

load python dict data to python class

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyruicore-0.1.3.tar.gz (7.9 kB view hashes)

Uploaded Source

Built Distribution

pyruicore-0.1.3-py3-none-any.whl (9.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page