Skip to main content

Pythonic agile application configuration helpers

Project description

PKonfig

Pragmatic, type-safe configuration for Python apps. PKonfig turns scattered env vars and config files into one clean, validated object with predictable precedence and great DX.

Why PKonfig

  • Avoid config spaghetti: declare your config as code, not as ad‑hoc parsing scattered around the app.
  • Fail fast: catch missing or invalid values at startup, not at 2 a.m. in production.
  • Predictable precedence: layer env vars, .env, YAML/JSON/TOML/INI in the order you choose.
  • Type-safe by default: fields convert and validate values; your IDE autocompletion just works.
  • Fast and lightweight: minimal dependencies, small surface area, no magic.
  • Framework-agnostic: works equally well in CLIs, services, scripts, and jobs.

What problems it solves

  • “Where does this setting come from?” → Single source of truth with clear precedence.
  • “Why did prod behave differently?” → Explicit, validated defaults and fail-fast checks.
  • “Why is this a string not an int?” → Built-in casting and validation for common types.

Key features

  • Typed, validated configuration objects
  • Multiple sources (env vars, .env, YAML, JSON, TOML, INI) with flexible precedence
  • Minimal dependencies, fail-fast checks, and great IDE autocompletion
  • Extensible API with high performance

Quick start

from pkonfig.config import Config
from pkonfig.fields import Str, Int, Bool
from pkonfig.storage.env import Env
from pkonfig.storage.yaml_ import Yaml

class App(Config):
    host = Str(default="127.0.0.1")
    port = Int(default=8000)
    debug = Bool(default=False)

# Highest precedence first
cfg = App(
    Env(prefix="APP"),
    Yaml("config.yaml", missing_ok=True),
)

print(cfg.host, cfg.port, cfg.debug)
# Env example: APP_PORT=9000 python app.py → 9000 overrides file/defaults

Install

pip install pkonfig
# extras for file formats
pip install pkonfig[yaml]
pip install pkonfig[toml]

Documentation

Links

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

pkonfig-2.0.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pkonfig-2.0.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file pkonfig-2.0.1.tar.gz.

File metadata

  • Download URL: pkonfig-2.0.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for pkonfig-2.0.1.tar.gz
Algorithm Hash digest
SHA256 1b71862cd7659275433acf824f101b2212a3f86ca887c3bfd942a5193a37ca58
MD5 25e6be1a3d6701a12e6ec62f92d7988b
BLAKE2b-256 19f155302ebc708ddcb5fd841d2b93fe8e220f3604a8f5abc1c799575d6d25e3

See more details on using hashes here.

File details

Details for the file pkonfig-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: pkonfig-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for pkonfig-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ba42168c62817cb63c8274ad0b387bddf7ac8747b32f5bcbaa617b5d9e1d544
MD5 bb545129ec14a970b18367f91cc8bbc2
BLAKE2b-256 f37c818d557c5c11ef50afe7b9fa24abcd8eb341771ba5934f746913ed910102

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page