Skip to content

Preserve comments on list items #171

@jacebrowning

Description

@jacebrowning

This test demonstrates the expected functionality:

def with_comments_on_list_items(expect):
sample = SampleWithListOfDataclasses()
write(
'tmp/sample.yml',
"""
# Header
items: # Subheader
# Section
- name: a # Item
score: 1
# Section
- name: b # Item
score: 2
""",
)
sample.datafile.load()
sample.items[1].name = 'c'
sample.datafile.save()
expect(read('tmp/sample.yml')) == dedent(
"""
# Header
items: # Subheader
# Section
- name: a # Item
score: 1
# Section
- name: c # Item
score: 2
"""
)

This appears to be an issue with the YAML library: https://sourceforge.net/p/ruamel-yaml/tickets/318/

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions