tilsit-config
tilsit-config is a lightweight Python utility for loading and managing
application configuration stored in TOML format.
It provides built-in support for settings modeled as dataclasses,
including boolean switches and selectable option lists.
This library is designed to simplify building UIs or CLI tools that allow users to update configuration values safely.
✨ Features
- Load config values from a TOML file
- Automatically map TOML data into dataclass-based settings
- Built-in setting types:
SettingBoolean— boolean configuration valuesSettingOptions— selectable values from predefined choices
- Track whether settings have changed
- Save user-modified settings back to the file
- Fully typed (mypy-friendly)
📦 Installation
pip install tilsit-config
🧩 Usage
Define your settings
from dataclasses import dataclass
from tilsit_config.settings import SettingBoolean, SettingOptions, SettingOption
@dataclass
class AppSettings:
dark_mode: SettingBoolean
language: SettingOptions
Example config.toml
[settings]
dark_mode = { label = "Dark Mode", default_value = false, current_value = true }
[settings.language]
label = "Language"
default_value = "en"
current_value = "pl"
[[settings.language.options]]
value = "en"
display_str = "English"
[[settings.language.options]]
value = "pl"
display_str = "Polish"
Loading and Saving Configuration
from tilsit_config import load_config, save_settings
config_path = "config.toml"
config_dict, settings = load_config(config_path, AppSettings)
print(settings.dark_mode)
print(settings.language.current_value)
# Modify a setting in code
settings.dark_mode.current_value = False
# Save back to file
save_settings(config_path, settings)
🔍 Detect changes
if settings.dark_mode.changed:
print("Dark mode setting was changed.")
🗂 Structure of returned data
| Variable | Type | Description |
|---|---|---|
config_dict |
dict[str, Any] |
Raw TOML document |
settings |
Instance of provided dataclass or None |
Mapped settings |
💡 Use cases
- TUI/GUI applications with persistent user preferences
- CLI tools with configuration overrides
- Games storing language/theme
- Feature toggles in config-driven apps
🤝 Contributing
Contributions, suggestions and issue reports are welcome!
📝 License
MIT License — see LICENSE for details.
Metadata
Release files for tilsit-config 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tilsit_config-1.0.1.tar.gz | 318.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tilsit_config-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 719.5 kB
Release files / tilsit_config-1.0.1.tar.gz
| Download URL | tilsit_config-1.0.1.tar.gz |
|---|---|
| Size | 318.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d0a449d6f94d5a84282bdf80d85440e755655f655ab65dd2be54a95839315f4
|
|
BLAKE2b-256 checksum How to use checksums |
a9709860d16d88eccef6c2365f868eba9d9192f0b2ab91cb2fca7051d0c51717
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.2
|
Release files / tilsit_config-1.0.1-py3-none-any.whl
| Download URL | tilsit_config-1.0.1-py3-none-any.whl |
|---|---|
| Size | 401.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
460ec70f4ed3f9758a4f026c29c8e827cfdd4d9493a53515aaed7514f43ba3b8
|
|
BLAKE2b-256 checksum How to use checksums |
43da2760470e812b239ce1183db07277c7ae446e9ba45122b4e84a6d3f9537e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.2
|