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.
How It Works¶
- On startup, the module scans for all
settings.pyfiles inside the library and in the path defined by thePROJECT_ROOTenvironment variable. - Every public variable (not starting with
_) found in those files is loaded into thesettingsobject. - When you read a setting, the value is resolved in the following priority order:
- Context (set via
SettingsManager) — highest priority - Instance (set directly on the
settingsobject at runtime) - Environment variable (e.g.
export MY_SETTING=value) - Default declared in the
settings.pyfile — lowest priority
Defining Settings¶
Create a settings.py file anywhere in your project and declare your variables:
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.