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

Request: ability to use double quotes #53

Open
jamesbraza opened this issue Oct 2, 2023 · 2 comments
Open

Request: ability to use double quotes #53

jamesbraza opened this issue Oct 2, 2023 · 2 comments

Comments

@jamesbraza
Copy link

Python black prefers double quotes: https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings

Since I use Python, I like my YAML to use double quotes too. Running this tool on my repo moves it to use single quotes:

-        if: "github.event_name == 'release' && github.event.action == 'published'"
+        if: github.event_name == 'release' && github.event.action == 'published'

There is the --preserve-quotes option, which leads to not touching quotes at all. I actually like when this tool makes changes like this, so I want to keep --preserve-quote on:

-                  cache: "pip"
+                  cache: pip

My request is to add a new option resembling black's --skip-string-normalization that will just not convert double quotes to single quotes.

@aeisenbarth
Copy link

To me, black's description for --skip-string-normalization sounds analog to --preserve-quotes:

If this option is given, strings are left unchanged instead.

Is that your request, or rather an option to enforce a certain type of quotes?
For my project, I wanted to enforce double quotes because:

  1. unquoted strings in YAML can cause unexpected behavior (no → bool, trailing spaces being included in strings…) and
  2. the preferred type of quotes depends on the context and should be configurable.

How should such an option look like?

  • --preserve-quotes | --single-quotes | --double-quotes
  • --quotes="preserve" | --quotes="single" | --quotes="double"
  • --quotes-style=…

@jamesbraza
Copy link
Author

Yeah @aeisenbarth, thanks for the follow up question. I agree in hindsight my OP was a little vague. I am interested in the ability to format with double quotes as opposed to single quotes. I think your proposed options --double-quotes or --quotes=double look great

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