Typed Settings#
Safe and flexible settings with types
Typed Settings allows you to cleanly structure and validate your settings with attrs classes. Type annotations will be used to automatically convert values to the proper type (using cattrs). You can currently load settings from these sources:
TOML files (multiple, if you want to). Paths can be statically specified or dynamically set via an environment variable.
Environment variables
click command line options
You can use Typed settings, e.g., for
server processes
containerized apps
command line applications
Installation#
Install and update using pip:
$ python -m pip install typed-settings
You can install install dependencies for optional features via
$ python -m pip install typed-settings[<feature>]
Available features:
typed-settings[click]
: Enable support for Click optionstyped-settings[option-groups]
: Enable support for Click and Click option groups
Example#
This is a very simple example that demonstrates how you can load settings from environment variables.
import typed_settings as ts
@ts.settings
class Settings:
option_one: str
option_two: int
settings = ts.load(
cls=Settings,
appname="example",
config_files=(ts.find("settings.toml"),), # Paths can also be set via env var
)
print(settings)
[example]
option_one = "value"
$ EXAMPLE_OPTION_TWO=2 python example.py
Settings(option_one='value', option_two=2)
Documentation#
Contents:
- Why Typed Settings?
- Getting Started
- Examples
- Guides
- API Reference
- Development
- Changelog
- 23.1.0 (unreleased)
- 23.0.1 (2023-05-23)
- 23.0.0 (2023-03-07)
- 2.0.2 (2023-01-18)
- 2.0.1 (2023-01-14)
- 2.0.0 (2022-11-30)
- 1.1.1 (2022-10-08)
- 1.1.0 (2022-07-09)
- 1.0.1 (2022-04-04)
- 1.0.0 (2022-03-04)
- 0.11.1 (2021-10-03)
- 0.11.0 (2021-10-02)
- 0.10.0 (2021-06-23)
- 0.9.2 (2021-02-10)
- 0.9.1 (2020-12-01)
- 0.9 (2020-11-29)
- 0.8 (2020-11-05)
- 0.7 (2020-10-13)
- 0.6 (2020-10-11)
- 0.5 (2020-09-30)
- 0.4 (2020-09-25)
- 0.3 (2020-09-17)
- 0.2 (2020-09-02)
- 0.1 (2020-08-28)
- Legend
- License