didactic-settings
didactic-settings loads typed application settings into a dx.Model. It adds
the didactic.settings module with sources for environment variables, dotenv
files, JSON, TOML, YAML, and parsed command-line arguments.
Install
pip install didactic-settings
pip install 'didactic-settings[yaml]'
The yaml extra installs PyYAML for .yaml and .yml files.
Load settings
from didactic.settings import EnvSource, FileSource, Settings
class AppSettings(Settings):
db_url: str
debug: bool = False
port: int = 8080
__sources__ = (
FileSource(path="config.toml"),
EnvSource(prefix="APP_"),
)
settings = AppSettings.load(db_url="postgresql://localhost/app")
source = settings.__provenance__["port"]
AppSettings.load() reads the declared sources, applies keyword overrides, and
then validates the result as a Didactic model. __provenance__ records whether
each value came from a source, a default, or a keyword override.
Source precedence
Sources run in declaration order. A later source overrides values supplied by
an earlier one, and keyword arguments to Settings.load(...) take final
precedence.
| Source | Input |
|---|---|
EnvSource(prefix="APP_") |
environment variables |
DotEnvSource(path=".env", prefix="APP_") |
a dotenv file |
FileSource(path="config.toml") |
JSON, TOML, or YAML selected by suffix |
CliSource(args=namespace) |
an argparse.Namespace or mapping |
Because Settings extends dx.Model, loaded values receive the same type
checks, axioms, field validators, and indexed-field checks as other Didactic
models.
Documentation
See the settings guide for source configuration, coercion rules, and provenance reporting.
License
Released under the MIT License.
Metadata
Release files for didactic-settings 0.16.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 | |
|---|---|---|---|
| didactic_settings-0.16.0.tar.gz | 5.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| didactic_settings-0.16.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.7 kB
Release files / didactic_settings-0.16.0.tar.gz
| Download URL | didactic_settings-0.16.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dbff59fda3112ce145c9789cf6678af2e03e3167ef5cf3965b92161dbb7a7664
|
|
BLAKE2b-256 checksum How to use checksums |
3469aa8c10941b8d5ecad52a0073b03ee5f8626c35953c587322c1b515761e67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logRelease files / didactic_settings-0.16.0-py3-none-any.whl
| Download URL | didactic_settings-0.16.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8e9a52ed5882472f054b4a9b6f5e85051a57c087fe76cc2923bd96f34e3a435
|
|
BLAKE2b-256 checksum How to use checksums |
83011acb6f85d9bacc7b16d86d35bd06ed8548a9ff8b4c4e5a1af700064b72a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency log