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](https://img.shields.io/pypi/v/dature)](https://pypi.org/project/dature/) [![Supported Python versions](https://img.shields.io/pypi/pyversions/dature)](https://pypi.org/project/dature/) [![Documentation](https://readthedocs.org/projects/dature/badge/?version=latest)](https://dature.readthedocs.io/) [![License](https://img.shields.io/github/license/Niccolum/dature.svg)](https://github.com/Niccolum/dature/blob/main/LICENSE) \ [![CI](https://github.com/Niccolum/dature/actions/workflows/ci.yml/badge.svg)](https://github.com/Niccolum/dature/actions/workflows/ci.yml) [![CodeQL](https://github.com/Niccolum/dature/actions/workflows/scorecard.yml/badge.svg)](https://github.com/Niccolum/dature/actions/workflows/scorecard.yml) [![Dependency Review](https://github.com/Niccolum/dature/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/Niccolum/dature/actions/workflows/dependency-review.yml) \ [![Monthly downloads](https://static.pepy.tech/badge/dature/month)](https://pypi.org/project/dature/) [![Commits since latest release](https://img.shields.io/github/commits-since/Niccolum/dature/latest?logo=github)](https://github.com/Niccolum/dature/commits) [![Last commit date](https://img.shields.io/github/last-commit/Niccolum/dature?logo=github&label=Last%20Commit)](https://github.com/Niccolum/dature/commits) [![Last release date](https://img.shields.io/github/release-date/Niccolum/dature?logo=github&label=Release%20Date)](https://github.com/Niccolum/dature/releases)

Documentation | Changelog

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 LoadMetadata, load

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

config = load(LoadMetadata(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)
  • 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@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/Niccolum/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

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.14.0.tar.gz (194.9 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.14.0-py3-none-any.whl (75.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dature-0.14.0.tar.gz
Algorithm Hash digest
SHA256 61e87fd1ac1d5b70214cf6f3aebc781d09c96fe6d6450571fefd4403855daf61
MD5 d03b915b3694cd23023f32530f970bc0
BLAKE2b-256 b6ca5b7fca2f6f6e48134eaaa126ec2c9ac5fb90a18e4e40f03e538251370d39

See more details on using hashes here.

Provenance

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

Publisher: ci.yml on Niccolum/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.14.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for dature-0.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e8b0ca1971517c9c9d9fb47b80013ae5f270a003fc5043577e5779074d94792
MD5 950e49ccacc5cf3773c0113258a71676
BLAKE2b-256 c83289e27949ecac0793e5cea169018cbfb7059e2ea8a50c9a113df05ddbdc93

See more details on using hashes here.

Provenance

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

Publisher: ci.yml on Niccolum/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