Safer access to settings (validation, typehinting and default values placed in a single place)
Things done:
- separate env for dev settings (so now things like force_onboarding or debug loop are not stored next to other settings in the
settings.toml
file more important for user) - introduced SafeSettings class which should be now used for getting settings. compared to previous approach it has some advantages:
- is fully type-hinted so there will be no typo or receiving the wrong type possible
- does validation on setting access and initially right after clive launch. Previously it was possible to have an error later in a misleading place which would require harder debugging
- default values (when no setting is found in the
settings.toml
file) are now defined in a single place. Previously there were multiple places likesettings.get("NODE.REFRESH_RATE", 1.5)
- Note: in the future (probably after dynaconf 4.0.0, the approach of defining Validators via dyanconf and having official stable typed dynaconf might be better solution)
- replaced all dynamic settings change from
settings.SOMETHING = "new"
orsettings["SOMETHING"] = "new"
tosettings.set("SOMETHING", "new")
as it is better searchable
Edited by Mateusz Żebrak