yamlpath
yamlpath copied to clipboard
Deleting keys deletes post-comment instead of pre-comment
Operating System
- Name/Distribution: ANY
- Version: ANY
Version of Python and packages in use at the time of the issue.
- Distribution: ANY
- Python Version: ANY Supported
- Version of yamlpath installed: 3.6.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:
- 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
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.
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.