Typed application settings on top of didactic Models.
Project description
didactic-settings
Typed application settings on top of dx.Model. Contributes
didactic.settings to the namespace package.
Install
pip install didactic-settings
pip install 'didactic-settings[yaml]' # adds YAML support
The package depends on didactic. The optional yaml extra adds
PyYAML for .yaml / .yml config files.
Usage
import didactic.api as dx
from didactic.settings import Settings, EnvSource, FileSource
class AppSettings(Settings):
debug: bool = False
db_url: str
port: int = 8080
__sources__ = (
FileSource(path="config.toml"),
EnvSource(prefix="APP_"),
)
cfg = AppSettings.load()
cfg.port # the resolved value
cfg.__provenance__["port"] # 'env' / 'file' / 'default' / 'override'
Settings inherits from dx.Model, so every Model feature works:
type checks, axioms, validators, JSON Schema export.
Sources
| source | reads from |
|---|---|
EnvSource(prefix="APP_") |
environment variables |
DotEnvSource(path=".env", prefix="APP_") |
dotenv file |
FileSource(path="config.toml") |
JSON, TOML, or YAML by suffix |
CliSource(args=ns) |
parsed argparse.Namespace or dict |
Sources are walked in declaration order; later sources override
earlier ones. Keyword overrides at Settings.load(...) win over
every source.
Documentation
See Guides > Settings for the full source documentation, coercion rules, and provenance reporting.
License
MIT.
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
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 didactic_settings-0.1.0.tar.gz.
File metadata
- Download URL: didactic_settings-0.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d391cfb8e2514803f972d117ab84b12942746274248ab391a3587ccf998c104
|
|
| MD5 |
97a0932f72b5164e7d2ffdb9dafdae9e
|
|
| BLAKE2b-256 |
7d25356c4a08254d820b1dd9b1472259c5f008670ba52fa0b4d495844d591a57
|
File details
Details for the file didactic_settings-0.1.0-py3-none-any.whl.
File metadata
- Download URL: didactic_settings-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77a48997e48dd4da75b67f2b22d1cf95fa8d292df603e10d5649a2b07fc36069
|
|
| MD5 |
4f76f80328e93245c3014308d1ac8abb
|
|
| BLAKE2b-256 |
07cc82affc7cce212bb71a667253b0e43b6c7cd48bd2a31d7f9c8cae9647378a
|