Skip to content

utilityhub_config

A deterministic, typed configuration loader for modern Python applications. Load settings from multiple sources with clear precedence, comprehensive metadata tracking, and detailed validation errors.

What It Does

utilityhub_config resolves application configuration from multiple sources in a strict, explicit precedence order. Instead of magic or implicit behavior, you get:

  • Type-safe configuration - Full Pydantic v2+ validation
  • Multi-source support - TOML, YAML, .env, environment variables, runtime overrides
  • Utility functions - Get canonical config paths with get_config_path()
  • Metadata tracking - Know exactly where each setting came from
  • Deterministic resolution - Clear, predictable precedence order
  • Rich error reporting - Validation failures include sources, files checked, and precedence info

Quick Start

uv add utilityhub_config
from pydantic import BaseModel
from utilityhub_config import load_settings

class Config(BaseModel):
    database_url: str = "sqlite:///default.db"
    debug: bool = False

# Load and validate configuration
settings, metadata = load_settings(Config)

# Type-safe access
print(settings.database_url)

# Track where it came from
print(f"Source: {metadata.get_source('database_url').source}")

Documentation

Getting Started

Understanding How It Works

Usage Guides

Examples & Help

Key Concepts at a Glance

Precedence Order (lowest to highest):

Defaults < Global Config < Project Config < Dotenv < Environment Vars < Overrides

Metadata Tracking:

source = metadata.get_source("database_url")
print(source.source)        # Where it came from
print(source.source_path)   # File path or env var name
print(source.raw_value)     # Original value

Where to Go Next

👉 New here? Start with Getting Started

👉 Want to learn the design? Read Precedence Order

👉 Ready to code? Jump to Usage Guides

👉 Looking for examples? Check Examples

👉 Troubleshooting? See Troubleshooting