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

Quote strings that contain : #284

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lalten
Copy link

@lalten lalten commented Aug 5, 2024

Fixes #283

Checklist

  • Add test cases to all the changes you introduce
  • Update the documentation for the changes

@lalten lalten force-pushed the quote-colon-strings branch 4 times, most recently from fa5c3f4 to d618467 Compare August 5, 2024 19:33
@lalten
Copy link
Author

lalten commented Aug 5, 2024

@lyz-code Please have a look.
Tests pass locally but CI complains about outdated dependencies. That's really out of scope of this PR.

@lalten
Copy link
Author

lalten commented Aug 5, 2024

I just noticed this also "fixes" - repo: https://github.com/pre-commit/pre-commit-hooks to - repo: 'https://github.com/pre-commit/pre-commit-hooks' which I think is really stupid. I don't understand why #283 is an issue for some parsers anyways :(

Copy link
Owner

@lyz-code lyz-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lalten for your contribution, it looks great. However there are a pair of polishing comments, tell me what do you think about them.

Regarding the dependency broken CI, I agree with you that it's out of the scope of the PR. Sadly I don't have time to address this myself so I propose you two solutions:

  • Run make update and it will probably fix the issue
  • Disable the check in the CI configuration

Thanks

@@ -87,6 +87,7 @@ variable, use `fix_code`:
- item
- item
```
- Quote jobs.*.containers.volumes entries in GitHub Actions workflow yamls to not confuse GitHubs Yaml parser.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't say this is a feature, but a fix for an unexpected behavior, isn't it? If you agree I'd remove this line

def _quote_gha_container_volumes(
self, source_dict: CommentedMap | CommentedSeq
) -> None:
"""Quote jobs.*.container.volumes entries."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the phrasing of the docstring confusing. Wouldn't it be clearer something like prevent list strings to be converted to dictionaries?

I'd add an example of what this function fixes (the one in the issue is just fine)

I'd also change the name of the method, as it's not specific to gha_container_volumes, there may be other strings with colons that will benefit from this method

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

Successfully merging this pull request may close these issues.

yamlfix breaks volumes: ["/a:/b"] by removing the quoting, making the list item a mapping
2 participants