Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure no conflicting settings are specified in plandos #1562

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions SettingsList.py
Original file line number Diff line number Diff line change
Expand Up @@ -5413,6 +5413,28 @@ def validate_settings(settings_dict):
# Ensure that the given choice is a valid choice for the setting
elif info.choice_list and choice not in info.choice_list:
raise ValueError('%r is not a valid choice for setting %r. %s' % (choice, setting, build_close_match(choice, 'choice', info.choice_list)))
# Ensure no conflicting settings are specified
if info.disable != None:
for option, disabling in info.disable.items():
negative = False
if isinstance(option, str) and option[0] == '!':
negative = True
option = option[1:]
if (choice == option) != negative:
for other_setting in disabling.get('settings', []):
validate_disabled_setting(settings_dict, setting, choice, other_setting)
for section in disabling.get('sections', []):
for other_setting in get_settings_from_section(section):
validate_disabled_setting(settings_dict, setting, choice, other_setting)
for tab in disabling.get('tabs', []):
for other_setting in get_settings_from_tab(tab):
validate_disabled_setting(settings_dict, setting, choice, other_setting)

def validate_disabled_setting(settings_dict, setting, choice, other_setting):
if other_setting in settings_dict:
disabled_default = get_setting_info(other_setting).disabled_default
if settings_dict[other_setting] != disabled_default:
raise ValueError(f'{other_setting!r} must be set to {disabled_default!r} since {setting!r} is set to {choice!r}')

class UnmappedSettingError(Exception):
pass
Expand Down