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

Deleting keys deletes post-comment instead of pre-comment #170

Open
wwkimball opened this issue Sep 2, 2022 · 2 comments
Open

Deleting keys deletes post-comment instead of pre-comment #170

wwkimball opened this issue Sep 2, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@wwkimball
Copy link
Owner

Operating System

  1. Name/Distribution: ANY
  2. Version: ANY

Version of Python and packages in use at the time of the issue.

  1. Distribution: ANY
  2. Python Version: ANY Supported
  3. Version of yamlpath installed: 3.6.4
  4. Version of ruamel.yaml installed: ANY Supported

Minimum sample of YAML (or compatible) data necessary to trigger the issue

---
# test.yaml
key1: value1

# Pre-comment
remove_this: key

# Post-comment
keep_this: other key

Complete steps to reproduce the issue when triggered via:

  1. yaml-set --delete --change=/remove_this test.yaml

Expected Outcome

---
# test.yaml
key1: value1

# Post-comment
keep_this: other key

Actual Outcome

---
# test.yaml
key1: value1

# Pre-comment
keep_this: other key

As you can see, the Pre-comment was preserved while both the post-comment and all whitespace after the target key was deleted.

Screenshot(s), if Available

@wwkimball wwkimball self-assigned this Sep 2, 2022
@wwkimball wwkimball changed the title Deleting keys deleted post-comment instead of pre-comment Deleting keys deletes post-comment instead of pre-comment Sep 2, 2022
@wwkimball
Copy link
Owner Author

wwkimball commented Sep 2, 2022

This is a known issue with how ruamel.yaml handles comments (ca objects). Having said that, yamlpath should be able to compensate for this unexpected behavior.

@wwkimball
Copy link
Owner Author

The author of ruamel.yaml has indicated that I really should wait for the next release of his package before I tackle comment handling like this. Comments are complex, internal, and the API will be entirely unpredictable until he's done with his rewrite. So, for now, I'm shelving this.

@wwkimball wwkimball added the enhancement New feature or request label Jan 16, 2023
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
None yet
Development

No branches or pull requests

1 participant