Skip to main content

struct config using yaml

Project description

StructConf

PyPI Codecov

Config your project with yaml and validation.

Enjoy wirting your code with IDEs python type hint

Simple Usage

  1. Define your configuration class, with attribute type and default value
from structconf import StructConf

class SimpleConf(StructConf):
    a: int = 1
    b: str = "b"
  1. write your yaml config file (e.g simple.yaml)
a: 2
b: "123"
  1. load yaml config file to your struct class
conf = SimpleConf.load("simple.yaml")
assert conf.a == 2
assert conf.b == "123"

Advanced Usage

StructConf use pydantic to validate your yaml and python class. So we can use recursive modelto build complex configuration.

from structconf import StructConf

class AConf(StructConf):
    a: int = 1


class BConf(StructConf):
    b: int = 2


class ComplexConf(StructConf):
    aconf: AConf = AConf()
    bconf: BConf = BConf()

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

structconf-0.3.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

structconf-0.3.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file structconf-0.3.0.tar.gz.

File metadata

  • Download URL: structconf-0.3.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.7.10 Darwin/20.3.0

File hashes

Hashes for structconf-0.3.0.tar.gz
Algorithm Hash digest
SHA256 56623142de6e6c5395efdf8267a5f1b1e5e821ac71cc700df5a5c3e3413f2836
MD5 a0a189f4ad15f522923b9f4626705c36
BLAKE2b-256 e002ad390bcd2709ba953179027efb34b44d776a95b036296decfbfdc47698f3

See more details on using hashes here.

File details

Details for the file structconf-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: structconf-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.7.10 Darwin/20.3.0

File hashes

Hashes for structconf-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e521ae24764f4da532be9777c346e95819c803f814eacc8117d4dc235f91825f
MD5 69f4bb870b5cf9ca71a280ace9b05d36
BLAKE2b-256 7811da08514c48f8ef9e6b43e6d1d24e07f7ae913fd09337f97980244f8e11b5

See more details on using hashes here.

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