Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"string value is redundantly quoted with single quotes" when string is a timestamp #665

Open
dorak88783 opened this issue Apr 2, 2024 · 1 comment

Comments

@dorak88783
Copy link

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.

@adrienverge
Copy link
Owner

adrienverge commented Apr 2, 2024

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:

  1. Make dependabot YAML parser default to YAML 1.2 by default (so time: 06:00 resolves to a string, not a number).
  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants