Type-safe configuration loader for Python dataclasses with support for YAML, JSON, TOML, INI, ENV and environment variables
Project description
dature
Type-safe configuration loader for Python dataclasses. Load config from YAML, JSON, TOML, INI, ENV files, environment variables, and Docker secrets — with automatic type conversion, validation, and human-readable error messages.
Installation
pip install dature
With optional format support:
pip install dature[yaml] # YAML (ruamel.yaml)
pip install dature[json5] # JSON5
pip install dature[toml] # TOML (toml_rs)
pip install dature[secure] # Secret detection heuristics
Quick Start
from dataclasses import dataclass
from dature import Source, load
@dataclass
class Config:
host: str
port: int
debug: bool = False
config = load(Source(file_="config.yaml"), Config)
Key Features
- Multiple formats — YAML, JSON, JSON5, TOML, INI, ENV, environment variables, Docker secrets
- Merging — combine multiple sources with configurable strategies (
LAST_WINS,FIRST_WINS,RAISE_ON_CONFLICT) - Validation —
Annotatedfield validators, root validators,__post_init__support - Naming — automatic field name mapping (
snake_case↔camelCase↔UPPER_SNAKEetc.) - Secret masking — automatic masking in error messages and logs by field type, name, or heuristic
- ENV expansion —
$VAR,${VAR:-default}substitution in all file formats - Special types —
SecretStr,ByteSize,PaymentCardNumber,URL,Base64UrlStr - Debug report —
debug=Trueshows which source provided each field value - Decorator mode —
@load(meta)auto-loads config on dataclass instantiation with caching
See the documentation for detailed guides and API reference.
Requirements
- Python >= 3.12
- adaptix >= 3.0.0b11
Development
git clone https://github.com/reagento/dature.git
cd dature
uv sync --all-extras --all-groups
Run tests:
uv run pytest tests/ -v
Lint and type check:
uv run prek run --all-files
Build docs locally:
uv run mkdocs serve
Changelog
Each PR must include a towncrier fragment in the changes/ directory:
# Format: changes/<issue-or-pr-number>.<type>
# Types: feature, bugfix, doc, removal, misc
echo "Added support for YAML anchors." > changes/42.feature
Use +<description> instead of an issue number for changes without a linked issue:
echo "Fixed typo in error message." > changes/+fix-typo.bugfix
Releasing
- Run the Release workflow and choose bump type (
patch/minor/major). The next version is calculated from the latest git tag automatically. - The workflow builds the changelog from fragments and creates a PR.
- Merge the PR — CI automatically creates the tag, publishes to PyPI, creates a GitHub Release, and updates docs.
License
Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dature-0.15.3.tar.gz.
File metadata
- Download URL: dature-0.15.3.tar.gz
- Upload date:
- Size: 204.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae73eee36d1f0cc8e148cf96134b21d5a1bc15cfc14154009249f34361ecbcd3
|
|
| MD5 |
e7f9c4681b66ee5de1a7ce8545792c50
|
|
| BLAKE2b-256 |
ff124b15df4091f2f057c4e231040140290f5424fa82cfc204d1422596e1fd33
|
Provenance
The following attestation bundles were made for dature-0.15.3.tar.gz:
Publisher:
publish.yml on reagento/dature
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dature-0.15.3.tar.gz -
Subject digest:
ae73eee36d1f0cc8e148cf96134b21d5a1bc15cfc14154009249f34361ecbcd3 - Sigstore transparency entry: 1180524092
- Sigstore integration time:
-
Permalink:
reagento/dature@7df3158d74132ba5631382f953334eae5c4022f0 -
Branch / Tag:
refs/tags/v0.15.3 - Owner: https://github.com/reagento
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7df3158d74132ba5631382f953334eae5c4022f0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dature-0.15.3-py3-none-any.whl.
File metadata
- Download URL: dature-0.15.3-py3-none-any.whl
- Upload date:
- Size: 76.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5849a545f487caf3ffc14b0d3d55064844940d4a85dd18cec7f505410ff39738
|
|
| MD5 |
66622f1b575999a2214bda0bd64b763f
|
|
| BLAKE2b-256 |
9e1fc85304b13dddd8abcacc29882ae0f99f2f2a299433cbce926341831bd62c
|
Provenance
The following attestation bundles were made for dature-0.15.3-py3-none-any.whl:
Publisher:
publish.yml on reagento/dature
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dature-0.15.3-py3-none-any.whl -
Subject digest:
5849a545f487caf3ffc14b0d3d55064844940d4a85dd18cec7f505410ff39738 - Sigstore transparency entry: 1180524096
- Sigstore integration time:
-
Permalink:
reagento/dature@7df3158d74132ba5631382f953334eae5c4022f0 -
Branch / Tag:
refs/tags/v0.15.3 - Owner: https://github.com/reagento
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7df3158d74132ba5631382f953334eae5c4022f0 -
Trigger Event:
release
-
Statement type: