A lightweight and flexible configuration management library for Python applications, built on top of Pydantic.
It allows you to load and validate settings from multiple sources
(YAML/JSON files, environment variables, or custom loaders), merge them via strategy,
and supports hot-reload as well as multiprocess-safe sharing.
- Chain of loaders: load configuration from multiple sources (files, environment variables, custom loaders).
- Pydantic integration: validate the final config using a
BaseModel. - Flexible merge strategies: deep merge by default, with support for custom strategies.
- ProxyConfig: proxy object with
reload(),setup()methods and model attribute access. - Hot-reload support: update configuration at runtime without restarting the process.
- Multiprocessing storage: share configuration between processes using
multiprocessing.Manager().dict(). - Extensibility: plug in custom loaders, merge strategies, and storages.
pip install qstd-configfrom pydantic import BaseModel
from qstd_config import ConfigManager
class AppConfig(BaseModel):
class DB(BaseModel):
host: str = "localhost"
port: int = 5432
debug: bool = False
db: DB
manager = ConfigManager(
AppConfig,
project_name="My App",
config_paths=["./config.yaml"],
default_config_values={"debug": False},
)
config = manager.load_config_model()
print(config.db.host, config.db.port, config.debug)The list of supported environment variables is automatically generated based on the structure of the config model.
You can override variable names explicitly via json_schema_extra in Pydantic’s Field. For example:
from pydantic import BaseModel, Field
class AppConfig(BaseModel):
class DB(BaseModel):
host: str = Field("localhost")
port: int = Field(5432, json_schema_extra={'env': 'DATABASE_PORT'})
debug: bool = False
db: DBRecognized environment variables:
DEBUGDB_HOSTDATABASE_PORT
If project_name="My App" is specified, variables will be prefixed:
MY_APP_DEBUGMY_APP_DB_HOSTMY_APP_DATABASE_PORT
You can provide configuration file paths from multiple sources. The order below defines the precedence (higher overrides lower):
- CLI argument:
--config=/path/to/config.yaml - Environment variable:
MY_APP_CONFIG=/path1.yaml;/path2.yaml config_pathsargument passed explicitly to the manager
pytest --cov=qstd_config --cov-report=term-missingTested on Python 3.9-3.13.
MIT License