StructConf
Config your project with yaml and validation.
Enjoy wirting your code with IDEs python type hint
Simple Usage
- Define your configuration class, with attribute type and default value
from structconf import StructConf
class SimpleConf(StructConf):
a: int = 1
b: str = "b"
- write your yaml config file (e.g simple.yaml)
a: 2
b: "123"
- 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()
Metadata
Release files for structconf 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| structconf-0.3.0.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| structconf-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.2 kB
Release files / structconf-0.3.0.tar.gz
| Download URL | structconf-0.3.0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56623142de6e6c5395efdf8267a5f1b1e5e821ac71cc700df5a5c3e3413f2836
|
|
BLAKE2b-256 checksum How to use checksums |
e002ad390bcd2709ba953179027efb34b44d776a95b036296decfbfdc47698f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.5 CPython/3.7.10 Darwin/20.3.0
|
Release files / structconf-0.3.0-py3-none-any.whl
| Download URL | structconf-0.3.0-py3-none-any.whl |
|---|---|
| Size | 3.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e521ae24764f4da532be9777c346e95819c803f814eacc8117d4dc235f91825f
|
|
BLAKE2b-256 checksum How to use checksums |
7811da08514c48f8ef9e6b43e6d1d24e07f7ae913fd09337f97980244f8e11b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.5 CPython/3.7.10 Darwin/20.3.0
|