Skip to content

Dracon

Dracon turns YAML configs into composable, type-safe Python objects. Define your schema as a Pydantic model, write your config in YAML with expressions and includes, and get a validated CLI for free.

What it looks like

config.yaml
log_level: ${getenv('LOG_LEVEL', 'INFO')}
workers: 2
database:
  host: db.${@/environment}.local
  port: 5432
  password: !include env:DB_PASS
app.py
from pydantic import BaseModel
from dracon import dracon_program, Arg
from typing import Annotated

@dracon_program()
class App(BaseModel):
    environment: Annotated[str, Arg(short='e')]
    log_level: str = "INFO"
    workers: int = 1
    database: DatabaseConfig

App.cli()
python app.py +config.yaml -e prod --workers 8

How it works

Dracon processes configuration in three phases:

  • Compose -- YAML files are parsed, includes resolved, merges applied, and instructions (!if, !define, !each) executed. The result is a single YAML node graph. No Python objects exist yet.
  • Construct -- The node graph is walked and turned into Python objects (Pydantic models, dicts, lists, primitives). Type validation happens here.
  • Resolve -- Interpolations like ${@/environment} are wrapped as lazy values and evaluated only when accessed. This lets expressions reference the final, fully-merged config.

Start here

Features