Skip to main content

Application configuration manager

Project description

qstd-config

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.


Key Features

  • 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.

Documentation


Install

pip install qstd-config

Quick start

from 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)

Environment variables

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: DB

Recognized environment variables:

  • DEBUG
  • DB_HOST
  • DATABASE_PORT

If project_name="My App" is specified, variables will be prefixed:

  • MY_APP_DEBUG
  • MY_APP_DB_HOST
  • MY_APP_DATABASE_PORT

Configuration paths

You can provide configuration file paths from multiple sources. The order below defines the precedence (higher overrides lower):

  1. CLI argument: --config=/path/to/config.yaml
  2. Environment variable: MY_APP_CONFIG=/path1.yaml;/path2.yaml
  3. config_paths argument passed explicitly to the manager

Tests

pytest --cov=qstd_config --cov-report=term-missing

Compatibility

Tested on Python 3.9–3.12.

License

MIT © QuisEgoSum

Copyright (c) 2025 QuisEgoSum

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

qstd_config-1.0.0.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

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

qstd_config-1.0.0-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file qstd_config-1.0.0.tar.gz.

File metadata

  • Download URL: qstd_config-1.0.0.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for qstd_config-1.0.0.tar.gz
Algorithm Hash digest
SHA256 50720f77439c156db1d2fbd6489717505facb46b6dd93baf1f5fd5c265c64deb
MD5 0936b634e530448720b77e27bc7b5fa3
BLAKE2b-256 3286f981d84c43b848dd9a0fc98d22b5fba48dbb54e3bbdb2f66d581dffda0ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for qstd_config-1.0.0.tar.gz:

Publisher: python-publish.yml on QuisEgoSum/qstd-config

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qstd_config-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: qstd_config-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for qstd_config-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03e40df593ef07259675ae92cd6b80a960d36fe3f24e4379582d03c86b5e375b
MD5 36d4cae2dab4cbf8496156098a751f24
BLAKE2b-256 3cb6798f4ecdf568a838ed4b46842a0f8e952d7e8e525af9e2a01e2dac020d10

See more details on using hashes here.

Provenance

The following attestation bundles were made for qstd_config-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on QuisEgoSum/qstd-config

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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