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

check-yaml false positive on unquoted scalar values with colon (e.g. URL) using flow style lists #862

Closed
tales-aparecida opened this issue Jan 18, 2023 · 1 comment

Comments

@tales-aparecida
Copy link

The check-yaml hook fails from v2.2.0 onward for scalar values containing a colon without quotes, for the example an URL:

[https://github.com/]
$ pre-commit run check-yaml --verbose --files example.yaml 
Check Yaml...............................................................Failed
- hook id: check-yaml
- duration: 0.05s
- exit code: 1

while scanning a plain scalar
  in "example.yaml", line 1, column 2
found unexpected ':'
  in "example.yaml", line 1, column 7

I believe this is a valid value since there's no space after the colon, as mentioned at pycontribs/ruyaml#86.

This issue can't be avoided by using the --unsafe argument, and this errors does not happen when using v2.1.0, when the hook was still using pyYAML instead of ruamel-yaml.

There's a ticket tracking this issue in there, but the solution provided involves using the Python interpreter instead of the C library. https://sourceforge.net/p/ruamel-yaml/tickets/248/
That would indeed solve the issue, but would be slower.

The workaround, besides using v2.1.0, is to wrap the value in quotes or use multi line lists.

@asottile
Copy link
Member

please search the issue tracker, there's at least one duplicate

@pre-commit pre-commit locked as resolved and limited conversation to collaborators Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants