larzconf
Layered, typed application configuration. Pure Python, zero dependencies.
Read configuration from defaults, files, .env, and environment variables —
layered so later sources win — and access it with the right types. No more
int(os.environ.get("PORT", "8000")) scattered through your code, and no
dependency to add.
from larzconf import Config
config = (Config()
.from_dict({"port": 8000, "debug": False}) # defaults
.from_file("config.json", optional=True) # committed config
.from_dotenv(".env") # local dev
.from_env(prefix="APP_")) # production wins
config.int("port") # int, not "8000"
config.bool("debug") # True / False from "true"/"1"/"yes"...
config.list("allowed_hosts") # comma-split -> list
config.get("db.host") # dotted access into nested config
config.get("secret_key", required=True) # raises if missing
Why
- Zero dependencies. No
python-dotenv, nopydantic-settings, no framework. Just the standard library. - The 12-factor layering you actually want. Defaults, then a config file,
then
.envfor local development, then real environment variables in production — each layer deep-merges over the last. - Typed, not stringly.
config.int(...),.bool(...),.float(...),.list(...)coerce values and raise a clearConfigErroron bad input;required=Truefails fast at startup instead of at 3am. - Nested & dotted. JSON config nests naturally; access it with
config.get("db.host"). Env vars map to nesting via__(APP_DB__HOST→db.host). - Validates end-to-end. Hand the whole config to a schema (
larzvalidate, or anything with.load(dict)) to type-check it once at boot.
Install
pip install larzconf
Loading
Config().from_dict({...}) # defaults / literals
.from_json("config.json") # a JSON file
.from_dotenv(".env") # KEY=VALUE (export/comments/quotes ok)
.from_env(prefix="APP_") # APP_PORT -> port, APP_DB__HOST -> db.host
.from_file(path, optional=True) # dispatch by extension
Each call returns the Config, so they chain, and each layer overrides the ones
before it.
Reading
config.get("key", default=None, cast=int, required=False)
config.int("port") config.float("ratio")
config.bool("debug") config.list("hosts") config.str("name")
config.get("db.host") # nested, dotted
"port" in config config["port"] config.as_dict()
Validate at startup (optional)
from larzvalidate import Schema, Integer, Boolean, String
class Settings(Schema):
port = Integer(min=1, max=65535, default=8000)
debug = Boolean(default=False)
secret_key = String(required=True)
settings = config.validate(Settings()) # cleaned, typed dict — or raises
larzconf doesn't depend on larzvalidate — validate() accepts anything with
a .load(dict) method.
Tests
python -m unittest discover -s tests -v # 25 tests, zero deps
The Larz stack
Pure-Python, zero-dependency building blocks: larz · larzchain · larzmoney · larzcrypt · larzdb · larzagent · larzchart · larzmark · larztask · larzvault · larzvm · larzcache · larzvalidate · larzid · larzrpc · larzstate · larzhttp · larzconf
License
MIT © larz-scripter
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 larzconf-0.1.0.tar.gz.
File metadata
- Download URL: larzconf-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c6d868ef235b5aac49711fb4237119ae4917f987e9a7a6b5e26559b919ff63c
|
|
| MD5 |
c82fc98fb072b5f0d1063b72efe83436
|
|
| BLAKE2b-256 |
8a457718db9f7606a322e2b8ae7d3bd9a7608debdf4d82a18813aaf024d7f101
|
File details
Details for the file larzconf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: larzconf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b34acd7429c8ad89d2c9e13daf8fc04d162f132256a13d3cd4b039847d11d52c
|
|
| MD5 |
bec34f3864cf6d5eefe160f0a099890f
|
|
| BLAKE2b-256 |
ea7fa041c0e80a691a36795031e7db1b35f8d579e558d393f399cd27d8628249
|