Skip to main content

Pythonic agile application configuration helpers

Project description

PKonfig logo

Configs for humans

pypi downloads versions license Type Checked with Mypy Code Quality - Pylint Code Style - Black Code Style - isort codecov

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
  • List values parsing with validation

Quick start

from pkonfig.config import Config
from pkonfig.storage.env import Env
from pkonfig.storage.yaml_ import Yaml

class App(Config):
    host: str = "127.0.0.1"
    port: int = 8000
    debug = 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.1.1.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

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

pkonfig-2.1.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pkonfig-2.1.1.tar.gz
Algorithm Hash digest
SHA256 7e7a41a296f9047e2691aedbde54d67662a422ee4ec4ddc9a1019d4611497019
MD5 bab97b507b96be8883e1533cfca37411
BLAKE2b-256 675c31d7fd7d6879a805c5e9be8225fbbae0fa549ca209069852e9e9d4a1db72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pkonfig-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.8 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f50e3f38e5cb9813f1a85614199fd52fcdcb2fa0e3d443f57b1849184988ab1
MD5 bf1fde45b0e001349e2515f78e860013
BLAKE2b-256 68f5ed68fe1e6c6ebd4f0208ae3845da0ab5563f5754f17acb7d6113b958d252

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