Skip to main content

Configuration Enhanced & Easy ☕️ - A Hydra-like configuration parser helper package

Project description

Language: 한국어 | English

Hydra-style Configuration + Pydantic Type Safety + Auto Help Generation

Python Version License: MIT Tests


☕️ Overview

confee makes configuration management in Python simple, type-safe, and intuitive. Combine Hydra-style config files, Pydantic validation, environment variables, and CLI arguments seamlessly.


✨ Features

  • 🎯 Type-Safe — Pydantic V2 validation & IDE autocomplete
  • 📋 Multi-Format — YAML, JSON, TOML auto-detection
  • 🔄 Override System — CLI args & environment variables
  • 🔐 Secret MaskingSecretField() for sensitive data
  • 🧊 Config Freezing — Runtime immutability
  • 📐 JSON Schema — Export & validate schemas
  • ⚡ Async Loading — Non-blocking I/O with file watching
  • 🔌 Plugin System — Custom format loaders
  • 💬 Auto Help--help flag support

📦 Installation

pip install confee

# Optional features
pip install confee[toml]    # TOML support (Python < 3.11)
pip install confee[remote]  # Async remote loading
pip install confee[all]     # All features

🚀 Quick Start

from confee import ConfigBase, SecretField

class AppConfig(ConfigBase):
    name: str
    debug: bool = False
    workers: int = 4
    api_key: str = SecretField(default="")  # Masked in output

config = AppConfig.load(config_file="config.yaml")
print(config.name)  # Type-safe access with IDE support
# config.yaml
name: my-app
debug: false
workers: 8
api_key: secret123
# Override via CLI
python app.py name=production debug=true

# Override via environment
export CONFEE_NAME=production
export CONFEE_DEBUG=true

🎯 Advanced Usage

Nested Configuration

class DatabaseConfig(ConfigBase):
    host: str = "localhost"
    port: int = 5432

class AppConfig(ConfigBase):
    name: str
    database: DatabaseConfig

# Override nested fields: python app.py database.host=prod.db

File References

api_key: "@file:secrets/api_key.txt"
database: "@config:configs/database.yaml"

Secret Masking

config.to_safe_dict()  # {'api_key': '***MASKED***', ...}
config.print(safe=True)  # Pretty print with masked secrets

Config Freezing

config.freeze()
config.name = "new"  # Raises AttributeError

# Create mutable copy
unfrozen = config.copy_unfrozen()

JSON Schema

schema = AppConfig.to_json_schema()
AppConfig.save_schema("config.schema.json")

Remote Config

# Sync (stdlib urllib)
data = ConfigLoader.load_remote("https://example.com/config.yaml")

# Async (requires aiohttp)
data = await AsyncConfigLoader.load_remote("https://example.com/config.yaml")

Plugin System

from confee import PluginRegistry

@PluginRegistry.loader(".ini")
def load_ini(path: str) -> dict:
    import configparser
    parser = configparser.ConfigParser()
    parser.read(path)
    return {s: dict(parser[s]) for s in parser.sections()}

Config Diff & Merge

diff = config1.diff(config2)  # {'name': ('app1', 'app2')}
merged = config1.merge(config2)  # config2 takes precedence

⚙️ Configuration Options

config = AppConfig.load(
    config_file="config.yaml",
    env_prefix="MYAPP_",  # Custom env prefix
    source_order=["cli", "env", "file"],  # Priority order
    strict=False,  # Allow unknown fields
)

🔄 Integration

FastAPI

config = AppConfig.load(config_file="config.yaml", source_order=["env", "file"])
app = FastAPI(title=config.name, debug=config.debug)

Kubernetes

env:
  - name: CONFEE_DEBUG
    value: "false"
  - name: CONFEE_WORKERS
    value: "16"

� License

MIT License © 2025 — See LICENSE for details.


Enjoy ☕️ configuration management!

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

confee-0.3.1.tar.gz (780.2 kB view details)

Uploaded Source

Built Distribution

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

confee-0.3.1-py3-none-any.whl (36.1 kB view details)

Uploaded Python 3

File details

Details for the file confee-0.3.1.tar.gz.

File metadata

  • Download URL: confee-0.3.1.tar.gz
  • Upload date:
  • Size: 780.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for confee-0.3.1.tar.gz
Algorithm Hash digest
SHA256 9f872f23d335dbecb1f61ae945e0826481da4a5f469287e80a7c2a28845d6fdd
MD5 011e661e0907ea3fcc016731ad43ac87
BLAKE2b-256 68bf44fc48690f87547df1241680f1525b5c04bd27b55323edb0dda63c6de9f2

See more details on using hashes here.

File details

Details for the file confee-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: confee-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 36.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for confee-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 34daacbe1b9d87714b6f7f7569303a9f655ca55e753abe8f98998dfd55cfcc32
MD5 96ac4629a7215d9c54c99cb448eb986f
BLAKE2b-256 c127ba90271758dfa3a0e1e512154827e95f71b16f74659ca7cc558c49c1249b

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