Clevis Documentation
Configuration management for Python projects with dataclass-based schemas.
About the Name
A clevis is a U-shaped mechanical fastener that connects components while allowing pivoting. It’s used in everything from agricultural equipment to aerospace control systems — a simple, robust connector that provides flexibility without compromising strength.
This library follows the same principle: it connects multiple configuration sources (TOML files, environment variables, CLI arguments) into a single, cohesive interface. Just as a mechanical clevis allows articulation, Clevis allows your configuration to flex and adapt — user-level defaults, project-level settings, and runtime overrides all pivot around a single dataclass schema.
- Installation
- Examples
- Overview
- Feature Matrix
- Learning Path
- Prerequisites
- Running Examples
- TOML Configuration Files
- Example 1: Basic Configuration (main.py)
- Example 2: Nested Configuration (nested.py)
- Example 3: Custom Validation (validation.py)
- Example 4: Environment Interpolation (environment.py)
- Example 5: Factory Pattern (factory.py)
- Example 6: Subcommands (commands.py)
- Example 7: Library Mode (library_mode.py)
- Example 8: Dynamic Registration (dynamic.py)
- Example 9: Plugin Pattern (plugin.py)
- Configuration Priority
- Security Features
- Next Steps
- Support
- Usage
- Overview
- Defining Configuration Schemas
- Loading Configuration
- TOML Configuration Files
- Environment Variable Interpolation
- CLI Argument Generation
- Factory Pattern for Multi-Module Apps
- Subcommands (CLI Applications)
- Layered Configuration (Precedence)
- Error Handling
- Testing with Configuration
- Security
- Dynamic Field Registration (Plugin Architecture)
- Complete Example
- Cookbook
- API Reference
Installation
# Python 3.11+ - no extras needed
pip install clevis
# Python 3.10
pip install clevis[tomli]
# Environment variable support
pip install clevis[envtoml]
Quick Start
from dataclasses import dataclass
from clevis import get_config
@dataclass
class Config:
name: str = "MyApp"
debug: bool = False
config = get_config(Config, name="app")
API Reference
For detailed API documentation, see the API Reference page.