structconfig
Strongly-typed configuration for Python, powered by msgspec.
load configuration from multiple sources with clear precedence:
- CLI arguments (highest priority)
- Environment variables
.envfiles- TOML / JSON / YAML files
- Struct field defaults (lowest priority)
Quick Start
from structconfig import Struct, field, load_config
class DatabaseConfig(Struct):
host: str = "localhost"
port: int = 5432
class AppConfig(Struct):
api_key: str # required field
debug: bool = False
db: DatabaseConfig = field(default_factory=DatabaseConfig)
# load_config from TOML file + env vars
config = load_config(
AppConfig,
files=["config.toml"],
env_prefix="APP",
)
print(config.api_key)
License
This project is a modified fork of saneconfig, licensed under MIT.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
structconfig-0.1.0.tar.gz
(90.5 kB
view details)
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 structconfig-0.1.0.tar.gz.
File metadata
- Download URL: structconfig-0.1.0.tar.gz
- Upload date:
- Size: 90.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dffc6c6b0301248109f16494acfd97aca296600308121aed82262df84392f2e7
|
|
| MD5 |
88a091beeeb0f9ad2acc2096cb13501a
|
|
| BLAKE2b-256 |
6817230bcdb67d6069ad5b6fb07cf5d0bf04c295866dec66c4959f2639fa6830
|
File details
Details for the file structconfig-0.1.0-py3-none-any.whl.
File metadata
- Download URL: structconfig-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cf50c0211d5e89fd1476a41ebe176774b2f059852028869bfda5fee676fd6a5
|
|
| MD5 |
7ef9b13d7ff578dd92ee4bcedbc17b5e
|
|
| BLAKE2b-256 |
a728907d3ec18cf82dbdfd7ed78cf923bb0f196cf2a6f68667a8fc750fc924ec
|