From d68022b846b0c2376f465706cbd1804408b83959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Fri, 10 Apr 2020 18:26:06 +0200 Subject: [PATCH] config: Allow generic types inside lists For example it's possible to define a conf like: rule: foo: [str], bar: [int, bool, 'magic'], --- yamllint/config.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yamllint/config.py b/yamllint/config.py index b72644c..a955d8e 100644 --- a/yamllint/config.py +++ b/yamllint/config.py @@ -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 '