You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm experiencing inconsistent comment spacing when using yaml_add_eol_comment with ruyaml. Specifically, the issue arises when adding end-of-line comments to YAML keys. Sometimes, the comment is not properly spaced, which can lead to formatting issues.
Steps to Reproduce:
Here's a minimal reproducible example:
fromioimportStringIOfromruyamlimportYAMLfromtextwrapimportdedentdefcheck_comment_spacing() ->None:
"""Check for comment spacing issue in ruyaml."""print("Starting check for comment spacing issue.")
yaml=YAML()
source=dedent(
""" parent: child1: value1 child2: value2 child3: value3 """
)
# Load YAML contentdata=yaml.load(source)
# Add commentsdata["parent"].yaml_add_eol_comment(key="child3", comment="this is a comment")
data["parent"].yaml_add_eol_comment(key="child2", comment="this is a comment")
data["parent"].yaml_add_eol_comment(key="child1", comment="this is a comment")
# Dump to a stringstring_stream=StringIO()
yaml.dump(data, string_stream)
source_code=string_stream.getvalue()
string_stream.close()
# Assert that there are two spaces between the value and the commentassert"value2 # this is a comment"insource_code, "Comment spacing issue detected!"assert"value3 # this is a comment"insource_code, "Comment spacing issue detected!"print("Comment spacing check completed.")
if__name__=="__main__":
check_comment_spacing()
Expected Behavior:
The output YAML should have two spaces between the value and the comment, like this:
parent:
child1: value1 # this is a commentchild2: value2 # this is a commentchild3: value3 # this is a comment
Actual Behavior:
The second comment only adds one space :S
parent:
child1: value1 # this is a commentchild2: value2 # this is a commentchild3: value3 # this is a comment
Please let me know if you need any additional information or if there's a known workaround for this issue. Thank you for your help!
The text was updated successfully, but these errors were encountered:
I'm experiencing inconsistent comment spacing when using
yaml_add_eol_comment
with ruyaml. Specifically, the issue arises when adding end-of-line comments to YAML keys. Sometimes, the comment is not properly spaced, which can lead to formatting issues.Steps to Reproduce:
Here's a minimal reproducible example:
Expected Behavior:
The output YAML should have two spaces between the value and the comment, like this:
Actual Behavior:
The second comment only adds one space :S
Please let me know if you need any additional information or if there's a known workaround for this issue. Thank you for your help!
The text was updated successfully, but these errors were encountered: