Skip to content

Config

The config module provides a central settings object that aggregates all configuration values defined across the project. It automatically discovers every settings.py file inside the Everysk library and the project root, merges their variables into a single place, and exposes them through one import.

from everysk.config import settings


How It Works

  1. On startup, the module scans for all settings.py files inside the library and in the path defined by the PROJECT_ROOT environment variable.
  2. Every public variable (not starting with _) found in those files is loaded into the settings object.
  3. When you read a setting, the value is resolved in the following priority order:
  4. Context (set via SettingsManager) — highest priority
  5. Instance (set directly on the settings object at runtime)
  6. Environment variable (e.g. export MY_SETTING=value)
  7. Default declared in the settings.py file — lowest priority


Defining Settings

Create a settings.py file anywhere in your project and declare your variables:

# myproject/settings.py

API_URL = 'https://api.example.com'
MAX_RETRIES = 3
DEBUG = False

Once the module is imported, these values are immediately available through the shared settings object:

from everysk.config import settings

settings.API_URL
# 'https://api.example.com'

settings.MAX_RETRIES
# 3

settings.DEBUG
# False


Beyond the Root of the Project

One important thing to mention is that the settings.py file does not need to be in the root of the project. You can place it anywhere inside your project structure and it will still be discovered automatically:

myproject/
├── core/
│   ├── settings.py   ← discovered here
│   └── client.py
├── jobs/
│   ├── settings.py   ← and here
│   └── runner.py
└── main.py

All discovered settings.py files are merged into the same settings object, so variables from any of them are accessible through the same import.