Skip to content

Safer access to settings (validation, typehinting and default values placed in a single place)

Mateusz Żebrak requested to merge mzebrak/safe-settings into develop

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 like settings.get("NODE.REFRESH_RATE", 1.5)
  • replaced all dynamic settings change from settings.SOMETHING = "new" or settings["SOMETHING"] = "new" to settings.set("SOMETHING", "new") as it is better searchable
Edited by Mateusz Żebrak

Merge request reports