-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Enable configurable indentation #52
Comments
That format is valid YAML. |
Interesting; didn't realize the spec allowed for 0 spacing. However it seems it would fail some yaml linter; is it possible to specify a default format spacing? |
yq currently uses PyYAML for YAML encoding. If there is an option that can be passed to PyYAML to specify the spacing, then yes, we can make that happen. Can you take a look at the PyYAML docs and give an example of the option if it exists? |
From here there is some suggestions https://stackoverflow.com/questions/25108581/python-yaml-dump-bad-indentation but doesn't look like a native PyYAML option exists. Also there is a bug with indentation with lists in PyYAML (yaml/pyyaml#234) |
OK thanks. It looks like ruamel.yaml has that option. I'm going to take another look at switching away from PyYAML (it has a number of flaws). |
Can we switch to https://github.com/crdoconnor/strictyaml ? Will it fix the issue or not? |
No. It introduces too many incompatibilities with YAML features that are in common use. |
At this point I find there is no suitable replacement for PyYAML. Therefore this bug is blocked by yaml/pyyaml#234. |
Hello, I'm facing the same problem, my YAML lists are converted from
to
which introduces unecessary and hard-to-review changes. I would also like the possibility of defining custom indentation. PS: Thanks for this useful tool |
I did some further analysis of available tools at adrienverge/yamllint#62 (comment) . In short, It would be great if |
At this point I consider staying with PyYAML to be the safest course of action. PyYAML has at least 3 orders of magnitude more usage and exposure than ruamel.yaml, and recently regained tractable maintainership. This bug remains blocked by yaml/pyyaml#234. |
I have found a way to address this issue. By default, Released in v2.8.0, please test. |
@kislyuk it’s working for me |
e.g.
foo.json
yq -y . foo.json
When valid yaml should be:
The text was updated successfully, but these errors were encountered: