konfi
konfi lets you create config templates similar to dataclasses. These templates are then used to load the config from different sources. konfi guarantees that the loaded config corresponds to the template even going as far as making sure items of a list are of the right type.
This means you no longer have to worry about the validity of the config, if the config is correct it will load and if it isn't it will raise an error telling you why not.
Installation
You can install konfi from PyPI:
pip install konfi
Example
from typing import Optional
import konfi
@konfi.template()
class UserInfo:
name: str
country: Optional[str]
@konfi.template()
class AppConfig:
name: str = "konfi"
user: UserInfo
konfi.set_sources(
konfi.YAML("config.yml", ignore_not_found=True),
konfi.Env(prefix="app_"),
)
config = konfi.load(AppConfig)
greeting = f"Hello {config.user.name}"
if config.user.country:
greeting += f" from {config.user.country}"
print(greeting)
print(f"Welcome to {config.name}!")
For more examples see the examples/ directory.
Documentation
If you're ready to jump in, you can find the documentation on Read the Docs.
Metadata
Release files for konfi 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| konfi-0.2.1.tar.gz | 17.8 kB | Without provenance | Details for konfi-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| konfi-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for konfi-0.2.1-py3-none-any.whl |
Total release size: 41.1 kB
Release files / konfi-0.2.1.tar.gz
| Download URL | konfi-0.2.1.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1cf67f153bbc8e9fd4112b573f43bec9410438a61e67dbce9bbe9bde7892137e
|
|
BLAKE2b-256 checksum How to use checksums |
a3a7bcce30842ee817e0682472583dab77d0824ed6926e169fc1443a1385d6d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4
|
Release files / konfi-0.2.1-py3-none-any.whl
| Download URL | konfi-0.2.1-py3-none-any.whl |
|---|---|
| Size | 23.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e65f1a4b759cffc4fee219a1027ea61067c1c2bb62fac40fe420e6303610478f
|
|
BLAKE2b-256 checksum How to use checksums |
a80aa9cc5db11002c4b6144bfeadd6cc5355cee5c255af36ce5ada827a8aa7eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4
|
Security for konfi 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.