-
Notifications
You must be signed in to change notification settings - Fork 303
quoted-strings: add allow-quoted-quotes option #487
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
Conversation
allows strings like 'foo"bar' on `quote-type: double` and vice versa
adrienverge
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @rgeraskin, thanks for contributing!
Can you add tests? Make sure the new tests take example from existing ones and insert nicely, for a full coverage and easier code maintenance.
About the new option name: I propose allow-quoted-quotes instead of skip-quoted-quote, to use conventional "allow"/"forbid" of yamllint options, and the plural form.
Closes use-case with quotes inside the string from #424. But still no solution for escape sequences.
What do you mean by "no solution for escape sequences"?
to allow-quoted-quotes
make the docs more easily understandable: no need to specify `required: true` option
|
Hello @adrienverge, thanks for the detailed and fast feedback! I've added tests to cover all cases for this feature. Also, I agree with you about the feature name, I've renamed it to About "no solution for escape sequences". As stated in #424:
So to achieve this functionality yamllint should be able to determine escape sequences in a string and not to complain about wrong quotes even through |
|
Thanks for these modifications. The code in However for tests I would really prefer explicit YAML blocks, even if it causes a lot of repetition. It allows easy and reliable visual check of what we expect for correct/wrong YAML code. Example: def test_allow_quoted_quotes(self):
conf = 'quoted-strings: {required: true, quote-type: '"', allow-quoted-quotes: true}\n'
self.check('---\n'
'foo1: "[barbaz]"\n'
'foo2: "[bar'baz]"\n'
conf,
problem=...)
conf = 'quoted-strings: {required: false, quote-type: '"', allow-quoted-quotes: true}\n'
self.check('---\n'
'foo1: "[barbaz]"\n'
'foo2: "[bar'baz]"\n'
conf,
problem=...)
# quote-type: any should accept both:
'foo3: '[bar"baz]'\n'
'foo3: "[bar'baz]"\n'
# etc. |
Use explicit YAML blocks instead of loops. It allows easy and reliable visual check of what we expect for correct/wrong YAML code.
|
@adrienverge I've updated tests for |
adrienverge
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Roman, thanks for this cool addition to yamllint, and for your reactivity.
Let's merge this!
|
I see that the generated documentation is wrong, because the first backslash is removed: Do you think you could fix this in a new pull request? (Docs can be generated locally using |
|
@adrienverge my bad, I've fixed it in #490 thank you for review! |
|
Thank you for this, this is great! |

This PR implements
skip-quoted-quoteallow-quoted-quotesoption that allows strings like:'foo"bar'onquote-type: double"foo'bar"onquote-type: singleCloses use-case with quotes inside the string from #424. But still no solution for escape sequences.