A Python configuration management library for handling application settings and configuration files with ease.
Charonfig is a lightweight, Pythonic configuration management tool designed to simplify how you handle application configuration. It provides a clean interface for loading, validating, and managing configuration settings from various sources.
- Easy Configuration Loading: Simple API for loading configuration from files and environment variables
- Type Validation: Built-in validation using Pydantic for type safety
- Multiple Formats: Support for multiple configuration file formats
- Environment Integration: Seamless environment variable override support
- Type Hints: Full Python type hints support for IDE autocomplete
- Minimal Dependencies: Lightweight with minimal external dependencies
- Language: Python 100%
- Build System: Modern Python packaging with pyproject.toml
- Configuration: Setuptools with pyproject.toml
charonfig/
├── src/ # Source code package
│ └── charonfig/ # Main package directory
├── pyproject.toml # Project configuration and dependencies
├── MANIFEST.in # Package manifest
└── README.md # Documentation
pip install charonfiggit clone https://github.com/AAEO04/charonfig.git
cd charonfig
pip install -e .from charonfig import Config
# Load configuration
config = Config.from_file('config.yml')
# Access settings
database_url = config.get('database.url')
debug_mode = config.get('debug', default=False)from charonfig import Config
# Configuration with environment variable overrides
config = Config.from_file('config.yml', override_from_env=True)
# Environment variables override file settings
# e.g., export APP_DEBUG=truefrom charonfig import BaseConfig
from pydantic import Field
class AppConfig(BaseConfig):
"""Application configuration with type validation."""
debug: bool = Field(default=False, description="Enable debug mode")
database_url: str = Field(description="Database connection URL")
port: int = Field(default=8000, description="Application port")
log_level: str = Field(default="INFO", description="Logging level")
# Load and validate
config = AppConfig.from_file('config.yml')Charonfig supports multiple configuration file formats:
database:
url: postgresql://localhost/myapp
pool_size: 10
debug: false
port: 8000{
"database": {
"url": "postgresql://localhost/myapp",
"pool_size": 10
},
"debug": false,
"port": 8000
}debug = false
port = 8000
[database]
url = "postgresql://localhost/myapp"
pool_size = 10Load configuration from a file.
Parameters:
path(str): Path to configuration fileoverride_from_env(bool): Override settings with environment variables
Returns: Config instance
Get a configuration value.
Parameters:
key(str): Dot-notation key path (e.g., "database.url")default(Any): Default value if key not found
Returns: Configuration value or default
Set a configuration value.
Parameters:
key(str): Dot-notation key pathvalue(Any): Value to set
Export configuration as dictionary.
Returns: Dict representation of config
Base class for type-safe configuration using Pydantic:
from charonfig import BaseConfig
from typing import Optional
class DatabaseConfig(BaseConfig):
url: str
pool_size: int = 10
timeout: Optional[int] = None
class AppConfig(BaseConfig):
debug: bool = False
database: DatabaseConfig
port: int = 8000Charonfig automatically handles environment variable mapping:
# Application configuration
export CHARONFIG_DEBUG=true
export CHARONFIG_PORT=3000
export CHARONFIG_DATABASE_URL=postgresql://localhost/myappfrom charonfig import Config
class Config:
config = Config.from_file('config.yml', override_from_env=True)
DEBUG = config.get('debug')
DATABASE_URL = config.get('database.url')
SECRET_KEY = config.get('secret_key')from charonfig import BaseConfig
class ServiceConfig(BaseConfig):
service_name: str
api_key: str
log_level: str = "INFO"
config = ServiceConfig.from_file(f'config.{os.getenv("ENV")}.yml')from charonfig import BaseConfig
from pydantic import validator
class AppConfig(BaseConfig):
port: int
@validator('port')
def validate_port(cls, v):
if not (1 <= v <= 65535):
raise ValueError('Port must be between 1 and 65535')
return vgit clone https://github.com/AAEO04/charonfig.git
cd charonfig
pip install -e ".[dev]"pytestpython -m buildContributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Created: October 3, 2025
- Last Updated: October 3, 2025
- Language Composition: Python 100%
- Repository Size: 9 KB
- Visibility: Public
This project is open source and available publicly on GitHub.
For issues, questions, or feature requests, please visit the repository issues page.
- YAML/JSON/TOML format support
- CLI tool for configuration management
- Configuration schema validation
- Hot reload support
- Encrypted configuration values
- Configuration documentation generator