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.
Quickstart
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
Released under the MIT License.
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.3.1.tar.gz.
File metadata
- Download URL: didactic_settings-0.3.1.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d9948c9e5e8fddbd440778d11c3d8b05da7daef56cfe83fa4bc31be0f6233f0
|
|
| MD5 |
221aa7667b251377fb1a5882f8161311
|
|
| BLAKE2b-256 |
8274be5040e204b161d6d6a73cf5d4063345370751e9d12aadf3d4d50f49c427
|
Provenance
The following attestation bundles were made for didactic_settings-0.3.1.tar.gz:
Publisher:
release.yml on panproto/didactic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
didactic_settings-0.3.1.tar.gz -
Subject digest:
0d9948c9e5e8fddbd440778d11c3d8b05da7daef56cfe83fa4bc31be0f6233f0 - Sigstore transparency entry: 1422945471
- Sigstore integration time:
-
Permalink:
panproto/didactic@5aa0a2caf296c479497f3a139db05f6f1d4ed062 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/panproto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5aa0a2caf296c479497f3a139db05f6f1d4ed062 -
Trigger Event:
push
-
Statement type:
File details
Details for the file didactic_settings-0.3.1-py3-none-any.whl.
File metadata
- Download URL: didactic_settings-0.3.1-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e85b2fd95e544d825f1b857aabdb9ef453498b9eedfb831ffe1c390a80649510
|
|
| MD5 |
fa0b5258e30595beb44374cfd2f998c0
|
|
| BLAKE2b-256 |
b52b69ee3a2f9379f18f9bb34c7f5a14562a576f5d183952e52c0ce88c4fac84
|
Provenance
The following attestation bundles were made for didactic_settings-0.3.1-py3-none-any.whl:
Publisher:
release.yml on panproto/didactic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
didactic_settings-0.3.1-py3-none-any.whl -
Subject digest:
e85b2fd95e544d825f1b857aabdb9ef453498b9eedfb831ffe1c390a80649510 - Sigstore transparency entry: 1422945563
- Sigstore integration time:
-
Permalink:
panproto/didactic@5aa0a2caf296c479497f3a139db05f6f1d4ed062 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/panproto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5aa0a2caf296c479497f3a139db05f6f1d4ed062 -
Trigger Event:
push
-
Statement type: