Skip to main content

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, no pydantic-settings, no framework. Just the standard library.
  • The 12-factor layering you actually want. Defaults, then a config file, then .env for 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 clear ConfigError on bad input; required=True fails 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

Metadata

Release files for larzconf 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for larzconf 0.1.0
File Size Uploaded Provenance Actions
larzconf-0.1.0.tar.gz 7.9 kB Without provenance Details for larzconf-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for larzconf 0.1.0
File Interpreter ABI Platform Actions
larzconf-0.1.0-py3-none-any.whl Python 3 none any Details for larzconf-0.1.0-py3-none-any.whl

Total release size: 15.3 kB

Release files / larzconf-0.1.0.tar.gz

Download URL larzconf-0.1.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9c6d868ef235b5aac49711fb4237119ae4917f987e9a7a6b5e26559b919ff63c
BLAKE2b-256 checksum
How to use checksums
8a457718db9f7606a322e2b8ae7d3bd9a7608debdf4d82a18813aaf024d7f101
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / larzconf-0.1.0-py3-none-any.whl

Download URL larzconf-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b34acd7429c8ad89d2c9e13daf8fc04d162f132256a13d3cd4b039847d11d52c
BLAKE2b-256 checksum
How to use checksums
ea7fa041c0e80a691a36795031e7db1b35f8d579e558d393f399cd27d8628249
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for larzconf 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page