Skip to content

Commit fea5934

Browse files
committed
Do not default global option defaults to None
If a global option does not have a default value defined, we should not set the default value to None, because it prevents the users of the config object from supplying their own fallback values.
1 parent 1fb7c80 commit fea5934

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tuned/utils/global_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def __init__(self,config_file = consts.GLOBAL_CONFIG_FILE):
2020
def get_global_config_spec():
2121
"""
2222
Easy validation mimicking configobj
23-
Returns two dicts, first with default values (default None)
24-
global_default[consts.CFG_SOMETHING] = consts.CFG_DEF_SOMETHING or None
23+
Returns two dicts, first with default values (if there is one)
24+
global_default[consts.CFG_SOMETHING] = consts.CFG_DEF_SOMETHING
2525
second with configobj function for value type (default "get" for string, others eg getboolean, getint)
2626
global_function[consts.CFG_SOMETHING] = consts.CFG_FUNC_SOMETHING or get
2727
}
@@ -30,7 +30,7 @@ def get_global_config_spec():
3030
if opt.startswith("CFG_") and
3131
not opt.startswith("CFG_FUNC_") and
3232
not opt.startswith("CFG_DEF_")]
33-
global_default = dict((getattr(consts, opt), getattr(consts, "CFG_DEF_" + opt[4:], None)) for opt in options)
33+
global_default = dict((getattr(consts, opt), getattr(consts, "CFG_DEF_" + opt[4:])) for opt in options if hasattr(consts, "CFG_DEF_" + opt[4:]))
3434
global_function = dict((getattr(consts, opt), getattr(consts, "CFG_FUNC_" + opt[4:], "get")) for opt in options)
3535
return global_default, global_function
3636

0 commit comments

Comments
 (0)