Skip to main content

`konfetti` provides a framework-independent way for configuration of applications or libraries written in Python.

Project description

codecov Build Version Python versions License


konfetti is a Python configuration management library that simplifies the process of setting up your application to run on your company’s infrastructure.

This library will help you to retrieve secrets from Vault, manages the access to settings required by our monitoring services, such as Datadog and Sentry, and set up tests for evaluating your app’s behavior.

Konfetti manages your app’s configuration settings through lazy evaluation: It only calls and configures what your app needs and when it needs it.

Key benefits:

Configurable lazy evaluation - You can choose the moment when Konfetti will evaluate your the configuration of your app.

Faster & simpler test runs - No need for evaluating the configuration of the whole project if it’s not used.

Faster and flexible testing - Isolating small parts of your application no longer requires you to perform a complete setup for each test.

Integration with popular Web Application Frameworks - Konfetti can seamlessly work with Django, Flask, and Celery.

The interface design and features are heavily inspired by decouple, Django, envparse and dynaconf.


Before Konfetti can perform its tasks, you’ll need to create a settings module and then tell Konfetti the location of this module.

1. Creating the Settings Module

Please find the application settings, for your production, local, or other environments, using the following path: app_name/settings/

Next, please review the below code block and copy the relevant parts in your settings file.

> :warning: Variables need to be named with all uppercase letters, other variables will be ignored

> :warning: If your app requires Vault access, then you’ll need to specify `VAULT_ADDR` and `VAULT_TOKEN` in the settings module

# app_name/settings/
from konfetti import env, vault


DEBUG = env("DEBUG", default=False)
DATABASE_URI = vault("path/to/db")

Apart from the import statement from konfetti import env, vault, you can remove the settings for the features that you don’t use.

If, for instance, you don’t use a database, then you can remove the DATABASE_URI variable. Depending on your settings, it might also be called DB_URI, or similar.

Furthermore, you can remove VAULT_ADDR and VAULT_TOKEN if your app doesn’t require secrets.

2. Configuring the Access Point

# app_name/settings/
from konfetti import Konfig, AsyncVaultBackend

config = Konfig(vault_backend=AsyncVaultBackend("/secret/team"))

In your app’s environment variables, please add the KONFETTI_SETTINGS variable with the path to your settings module. In the case of the code block above, it would be:

export KONFETTI_SETTINGS=app_name.settings.production

Alternatively the access point could be initiated from an object, importable string, mapping or a JSON file:


class TestSettings:
    VALUE = "secret"
config = Konfig.from_object(TestSettings, ...)

Importable string

config = Konfig.from_object("", ...)

# If the config is in the same module
SECRET = vault("/path/to")["secret"]
config = Konfig.from_object(__name__, ...)


config = Konfig.from_mapping({"SECRET": 42}, ...)


config = Konfig.from_json("/path/to.json")


The settings module/class with configuration options shouldn’t be accessed directly, because the aforementioned features are implemented in the access point level.

from app_name.settings import config

async def something():
    await config.DATABASE_URI  # asynchronously taken from Vault
    debug = config.DEBUG  # Usual sync access


For full documentation, please see

Or you can look at the docs/ directory in the repository.

Python support

Konfetti supports Python 2.7, 3.5, 3.6, 3.7 and 3.8


The code in this project is licensed under MIT license. By contributing to konfetti, you agree that your contributions will be licensed under its MIT license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Built Distribution

konfetti-0.8.0-py2.py3-none-any.whl (26.0 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page