Repository navigation
Conversation
The default user settings lived in lute.db.management (add_default_user_settings) while the list of keys to coerce to bools lived separately in lute.settings.current (refresh_global_settings). Keeping the two in sync by hand was error prone and risked coercing an integer setting to a bool. Add lute/settings/setting_defaults.py, which records each user setting key's type and default value in one place, plus helpers: - user_setting_defaults(path): key -> default map (backup_dir filled in), used by add_default_user_settings. - bool_setting_keys(): keys whose stored string is coerced to bool, used by refresh_global_settings. Bool coercion is now derived from the declared types, so integer keys are never coerced. The backup_enabled/backup_auto/backup_warn flags are bool-typed and are now coerced consistently in the global settings dict; they are only read elsewhere via UserSettingRepository.get_backup_settings (which does its own coercion) and are not read from LUTE_USER_SETTINGS, so this has no functional impact. Refs #675.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Refs #675.
The default user settings were defined in
lute.db.management.add_default_user_settings, while the separate list of keys to coerce to booleans lived inlute.settings.current.refresh_global_settings. Keeping those two hand-maintained lists in sync was error prone, and (as noted in the issue) risked coercing an integer setting to a bool.Change
lute/settings/setting_defaults.pyas the single source:USER_SETTING_DEFINITIONSrecords each key'stype(bool/int/str) and defaultvalue, with two helpers:user_setting_defaults(default_user_backup_path)returns the key -> default map (withbackup_dirfilled in), consumed byadd_default_user_settings.bool_setting_keys()returns the keys to coerce to bool, consumed byrefresh_global_settings.add_default_user_settingsandrefresh_global_settingsnow both derive from that source, so defaults and bool-coercion can no longer drift, and integer keys are never coerced to bools.Behavior note
Bool coercion is now derived from the declared types. The
backup_enabled/backup_auto/backup_warnflags are bool-typed and are now coerced consistently in the global settings dict. These are only read elsewhere viaUserSettingRepository.get_backup_settings(which does its own coercion) and are not read fromLUTE_USER_SETTINGS, so there is no functional impact. All existing default values are unchanged.Tests
tests/unit/settings/test_setting_defaults.py: coversuser_setting_defaultsand thatbool_setting_keysmatches the bool-typed keys (and excludes integer keys).tests/unit/settings/test_current.py: asserts bool settings are coerced to real bools and integer settings are not.black clean, pylint 10.00/10. Existing settings and db-management tests pass.