mirror of
https://github.com/adrienverge/yamllint.git
synced 2024-11-22 07:36:25 -06:00
config: Allow generic types inside lists
For example it's possible to define a conf like: rule: foo: [str], bar: [int, bool, 'magic'],
This commit is contained in:
parent
851d34b9fd
commit
d68022b846
@ -157,11 +157,12 @@ def validate_rule_conf(rule, conf):
|
||||
raise YamlLintConfigError(
|
||||
'invalid config: option "%s" of "%s" should be in %s'
|
||||
% (optkey, rule.ID, options[optkey]))
|
||||
# Example: CONF = {option: ['flag1', 'flag2']}
|
||||
# → {option: [flag1]} → {option: [flag1, flag2]}
|
||||
# Example: CONF = {option: ['flag1', 'flag2', int]}
|
||||
# → {option: [flag1]} → {option: [42, flag1, flag2]}
|
||||
elif isinstance(options[optkey], list):
|
||||
if (type(conf[optkey]) is not list or
|
||||
any(flag not in options[optkey]
|
||||
any(flag not in options[optkey] and
|
||||
type(flag) not in options[optkey]
|
||||
for flag in conf[optkey])):
|
||||
raise YamlLintConfigError(
|
||||
('invalid config: option "%s" of "%s" should only '
|
||||
|
Loading…
Reference in New Issue
Block a user