Skip to content

Update YamlParser and YamlPrinter to support Mapping and Sequence anchors. (issue #1161) #2140

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

Merged
merged 1 commit into from
Aug 16, 2022

Conversation

pway99
Copy link
Contributor

@pway99 pway99 commented Aug 15, 2022

No description provided.

@github-actions
Copy link
Contributor

Test Results

   495 files   -    456     495 suites   - 456   44m 18s ⏱️ - 36m 29s
3 311 tests  -    262  3 202 ✔️  -    248  109 💤  - 14  0 ±0 
3 676 runs   - 4 190  3 565 ✔️  - 4 136  111 💤  - 54  0 ±0 

Results for commit 0021a9e. ± Comparison against base commit b37eb51.

- fuz: *anchor
- end: end
""")

@Disabled
Copy link
Collaborator

@nmck257 nmck257 Aug 15, 2022

Choose a reason for hiding this comment

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

Confirming scope:

  • This case (and scalarKeyAnchor up at line 224) are still disabled. And I believe YAML allows anchors on mapping keys, too. Are those included in this PR?
  • I see the mappingAnchor case below is no longer disabled, and it features the merge-key syntax <<. So, this PR covers Add support for merge in yaml grammar #2133, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This case (and scalarKeyAnchor up at line 224) are still disabled. relatedly, And I believe YAML allows anchors on mapping keys, too. Are those included in this PR?

Thanks for noticing, yes I would agree the YAML does allow anchors on mapping keys also.
https://yaml.org/spec/1.2.2/#3222-anchors-and-aliases

It's interesting though while the spec seems to allow defining an anchor for a key I have not been able to find a YAML validator that successfully validates the example.

Sequence entry validation error:

foo:
  - start: start
  - &anchor buz: buz ## Bad indentation for a sequence entry validation error
  - *anchor: baz
  - end: end

An example that passes validation:

bar:
  &abc yo: friend
baz:
  *abc: friendly

I will give this a bit more investigation and see if I can't make it work for keys also

I see the mappingAnchor case below is no longer disabled, and it features the merge-key syntax <<. So, this PR covers #2133, too?

Good question I will have a look and get back to you on that also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nmck257 I am going to merge these changes and leave the issue open then work on the keys having anchors and aliases in another PR

Copy link
Contributor

Choose a reason for hiding this comment

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

YamlLinter: link

@pway99 pway99 changed the title Update YamlParser and YamlPrinter to support Mapping and Sequence anchors. (fixes #1161) Update YamlParser and YamlPrinter to support Mapping and Sequence anchors. (issue #1161) Aug 16, 2022
@pway99 pway99 merged commit 834f019 into main Aug 16, 2022
@pway99 pway99 deleted the issue-1161 branch August 16, 2022 16:45
@tkvangorder tkvangorder added this to the 7.28.0 milestone Sep 2, 2022
@tkvangorder tkvangorder added the enhancement New feature or request label Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants