truthy: Validate options passed to 'allowed-values'

Make sure values passed in allowed values are correct ones. This is
possible thanks to previous commit, and should prevent users from
writing incorrect configurations.
This commit is contained in:
Adrien Vergé
2019-06-06 11:05:33 +02:00
parent f65553c4f7
commit 0ba193331b
2 changed files with 6 additions and 18 deletions

View File

@@ -98,10 +98,6 @@ import yaml
from yamllint.linter import LintProblem
ID = 'truthy'
TYPE = 'token'
CONF = {'allowed-values': list}
DEFAULT = {'allowed-values': ['true', 'false']}
TRUTHY = ['YES', 'Yes', 'yes',
'NO', 'No', 'no',
@@ -111,6 +107,12 @@ TRUTHY = ['YES', 'Yes', 'yes',
'OFF', 'Off', 'off']
ID = 'truthy'
TYPE = 'token'
CONF = {'allowed-values': list(TRUTHY)}
DEFAULT = {'allowed-values': ['true', 'false']}
def check(conf, token, prev, next, nextnext, context):
if prev and isinstance(prev, yaml.tokens.TagToken):
return