Config: Allow options to be in a pre-defined list

pull/4/head
Adrien Vergé 9 years ago
parent 8288a6f331
commit fb14cbdbd9

@ -83,10 +83,16 @@ def parse_config(content):
raise YamlLintConfigError( raise YamlLintConfigError(
'invalid config: unknown option "%s" for rule "%s"' % 'invalid config: unknown option "%s" for rule "%s"' %
(optkey, id)) (optkey, id))
if type(options[optkey]) == tuple:
if conf['rules'][id][optkey] not in options[optkey]:
raise YamlLintConfigError(
('invalid config: option "%s" of "%s" should be '
'in %s') % (optkey, id, options[optkey]))
else:
if type(conf['rules'][id][optkey]) != options[optkey]: if type(conf['rules'][id][optkey]) != options[optkey]:
raise YamlLintConfigError( raise YamlLintConfigError(
'invalid config: option "%s" of "%s" should be %s' % ('invalid config: option "%s" of "%s" should be '
(optkey, id, options[optkey].__name__)) '%s' % (optkey, id, options[optkey].__name__)))
rules[id][optkey] = conf['rules'][id][optkey] rules[id][optkey] = conf['rules'][id][optkey]
else: else:
raise YamlLintConfigError(('invalid config: rule "%s": should be ' raise YamlLintConfigError(('invalid config: rule "%s": should be '

Loading…
Cancel
Save