"string value is redundantly quoted with single quotes" when string is a timestamp
dorak88783 opened this issue · 1 comments
I have a dependabot.yml
file with
schedule:
interval: daily
time: "06:00"
The quotes around the time
value are really needed, as dependabot expects a string here. Dropping the quotes gives an error
The property '#/updates/0/schedule/time' of type integer did not match the following type: string
.
It seems that, without the quote, the field value is parsed as a base-60 integer: https://yaml.org/type/int.html. In theory, dependabot could accept integers as time values, but currently it only accepts string values.
yamllint suggests "string value is redundantly quoted with single quotes", which isn't correct: without the quotes, it would not be a string value.
Hello and thanks for the report!
The quotes around the
time
value are really needed
It depends whether your YAML file is YAML 1.1 or YAML 1.2. With version 1.2, sexagesimal numbers (base 60) like 06:00
or 190:20:30
don't exist anymore, so these resolve to simple strings, hence don't need quotes. If surrounded with quotes, they would be redundantly quoted.
Since yamllint tries to support the newer YAML version (1.2), its current behavior seems appropriate.
However, there is an ongoing effort to make yamllint adaptative depending on the detected YAML version. See for example #587 and #650.
To conclude, I see 2 solutions:
- Make dependabot YAML parser default to YAML 1.2 by default (so
time: 06:00
resolves to a string, not a number). - Enhance yamllint to change behavior depending on the YAML version of the document (would you like to develop such a change?) and start your YAML file with an explicit
%YAML 1.1
directive.