Skip to main content

Type-safe configuration loader for Python dataclasses with support for YAML, JSON, TOML, INI, ENV and environment variables

Project description

dature

PyPI Supported Python versions Documentation License
CI CodeQL Dependency Review Coverage
Monthly downloads Commits since latest release Last commit date Last release date

Documentation | Changelog

Type-safe configuration loader for Python dataclasses. Load config from YAML, JSON, TOML, INI, ENV files, environment variables, Docker secrets, CLI arguments, and HashiCorp Vault — 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[vault]      # HashiCorp Vault (hvac)
pip install dature[secure]     # Secret detection heuristics
pip install dature[type-stubs] # Type stubs for the integrations above (mypy/pyright users)

Quick Start

from dataclasses import dataclass

import dature

@dataclass
class Config:
    host: str
    port: int
    debug: bool = False

config = dature.load(dature.Yaml12Source(file="config.yaml"), Config)

Key Features

  • Multiple sources — YAML, JSON, JSON5, TOML, INI, ENV, environment variables, Docker secrets, CLI args (argparse), HashiCorp Vault
  • Merging — combine multiple sources with configurable strategies ("last_wins", "first_wins", "raise_on_conflict")
  • ValidationAnnotated field validators, root validators, __post_init__ support
  • Naming — automatic field name mapping (snake_casecamelCaseUPPER_SNAKE etc.)
  • 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 typesSecretStr, ByteSize, PaymentCardNumber, URL, Base64UrlStr
  • Debug reportdebug=True shows which source provided each field value
  • Decorator mode@dature.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>
echo "Added support for YAML anchors." > changes/42.feature

Available <type> values:

Type Description
feature New features
bugfix Bug fixes
doc Documentation improvements
removal Deprecations and removals
misc Other changes

Use +<description> instead of an issue number for changes without a linked issue:

echo "Fixed typo in error message." > changes/+fix-typo.bugfix.md

Releasing

  1. Run the Release workflow and choose bump type (patch / minor / major). The next version is calculated from the latest git tag automatically.
  2. The workflow builds the changelog from fragments and creates a PR.
  3. 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


Download files

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

Source Distribution

dature-0.22.0.tar.gz (348.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dature-0.22.0-py3-none-any.whl (136.6 kB view details)

Uploaded Python 3

File details

Details for the file dature-0.22.0.tar.gz.

File metadata

  • Download URL: dature-0.22.0.tar.gz
  • Upload date:
  • Size: 348.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for dature-0.22.0.tar.gz
Algorithm Hash digest
SHA256 b09444e5341f1e9a4d3cc91b0f3c3a770f1ec811d357910a8bfdea726fa6b196
MD5 fc4e93c1c1a16258fffdbde8859836eb
BLAKE2b-256 695e31aa1f3002f9a5eeda25c36ae63ea798d2b7c8622212027238a4bacd4548

See more details on using hashes here.

Provenance

The following attestation bundles were made for dature-0.22.0.tar.gz:

Publisher: publish.yml on reagento/dature

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dature-0.22.0-py3-none-any.whl.

File metadata

  • Download URL: dature-0.22.0-py3-none-any.whl
  • Upload date:
  • Size: 136.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for dature-0.22.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6cd54f7c5b225f1dc2c1a3504c3ad65e2e246885c940bb8c69d5f5522140cc08
MD5 57467b6ca176d9a05f37a46cab4c6561
BLAKE2b-256 9ed10f70a476bb626538c1c68595ecba97894ae214768b39f4da642a30b55c0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dature-0.22.0-py3-none-any.whl:

Publisher: publish.yml on reagento/dature

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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