ConfigCore provides a minimal, type-safe foundation for building configuration systems in Python applications. Rather than being a complete configuration solution, it defines contracts and base classes that can be extended to create application-specific configuration systems.
The library focuses on:
- π Providing a standardized way to handle environment selection
- π Managing log levels consistently across projects
- π§© Offering a base Settings class for extension
- π Using Pydantic for type validation and .env file loading
- Python 3.13 or higher
- uv for dependency management
-
Clone the repository
-
Install dependencies
make init
ConfigCore is designed to be extended in your projects. Here's how to use it:
from configcore import Settings
from pydantic import Field
class MyAppSettings(Settings):
"""Application-specific settings extending the base Settings class."""
# Add your application-specific settings
api_url: str = Field(default="https://api.example.com")
max_retry_count: int = Field(default=3, ge=1)
timeout_seconds: float = Field(default=30.0)
# Add custom methods as needed
def get_api_timeout(self) -> float:
if self.is_env_production():
return self.timeout_seconds
return self.timeout_seconds * 2# In your application
settings = MyAppSettings() # Loads from environment variables / .env
# Access standard settings from the base class
env = settings.get_environment() # Returns Environment enum
log_level = settings.get_log_level() # Returns LogLevel enum
is_prod = settings.is_env_production() # Convenience method
# Access your custom settings
api_url = settings.api_url
timeout = settings.get_api_timeout()This project uses ruff for formatting and linting:
# Format code
make format
# Run linters
make lint# Run tests with coverage
make test| Variable | Description | Default Value | Possible Values |
|---|---|---|---|
| ENVIRONMENT | Application environment | PRODUCTION | DEVELOPMENT, STAGING, PRODUCTION |
| LOG_LEVEL | Logging level | INFO | DEBUG, INFO, WARNING, ERROR, CRITICAL |
We welcome contributions to this project! Please see the CONTRIBUTING.md file for guidelines on how to contribute, including:
- How to set up your development environment
- Coding standards and style guidelines
- Pull request process
- Testing requirements
This project is licensed under the GNU General Public License v3.0 (GPL-3.0) - see the LICENSE file for details.
GPL-3.0 is a strong copyleft license that requires anyone who distributes your code or a derivative work to make the source available under the same terms.