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
Relax the yamllint rules on spaces inside braces for flow mappings #2077
Relax the yamllint rules on spaces inside braces for flow mappings #2077
Conversation
I'd need a hint on where to put tests for testing this change. I see that |
Let's see. This is where we add the extra space: ansible-lint/src/ansiblelint/yaml_utils.py Lines 587 to 611 in aa305f7
We would need to add a case for ansible-lint/src/ansiblelint/yaml_utils.py Lines 828 to 861 in aa305f7
And then save the braces setting somewhere here: ansible-lint/src/ansiblelint/yaml_utils.py Lines 780 to 787 in aa305f7
And pass that setting into the FormattedEmitter here ish: ansible-lint/src/ansiblelint/yaml_utils.py Lines 801 to 805 in aa305f7
So we can access it in Our default config needs to be compatible with prettier's default (add the space in flow-style maps), but I'm happy to respect the (potentially custom) yamllint config in more cases. |
This is the test for the FormattedEmitter: ansible-lint/test/test_yaml_utils.py Line 171 in aa305f7
So we might need additional test cases or an additional test function here to make sure we're respecting the yamllint config. |
This is the test that actually calls We might want to add a call in there to also run yamllint on the files and make sure our yamllint config is also compatible with prettier. That might mean adding something to one or more of the test fixture files (or adding a new fixture file) that has flow maps with too many + too few spaces. |
Thank you for working on this! I've been a little swamped and unable to get back to finishing the I will review whatever you do as quickly as I can however, because I hate holding up people's PRs. |
There's already a case here for too few spaces and I will add one more with too many spaces. ansible-lint/test/fixtures/formatting-before/fmt-1.yml Lines 25 to 26 in 6516fc9
|
5cca796
to
0530c90
Compare
@cognifloyd I got a first version that basically works. Also the tests were extended to test with yamllint after ruaml.yaml did it's thing. What is missing? Extending Do you see anything completely horrible for now? If you remove the new settings around this lines, the extended test fails. |
239f8ad
to
82108aa
Compare
@cognifloyd I think, this is now ready for review. |
I'm looking at the |
Fixes: ansible#2076 Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
0437aae
to
ffaaa71
Compare
This allows zero or one space inside braces for flow mappings.
Fixes: #2076