Skip to content

Commit

Permalink
fix: don't add header when removing items from a supertable (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Aug 8, 2022
1 parent ad7dfe0 commit f5b1cdc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions tests/test_toml_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,3 +983,21 @@ def test_add_newline_before_super_table():
[d.e]
"""
assert doc.as_string() == dedent(expected)


def test_remove_item_from_super_table():
content = """\
[hello.one]
a = 1
[hello.two]
b = 1
"""
doc = parse(dedent(content))
del doc["hello"]["two"]
expected = """\
[hello.one]
a = 1
"""
assert doc.as_string() == dedent(expected)
3 changes: 2 additions & 1 deletion tomlkit/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ def _render_table(

if not table.is_super_table() or (
any(
not isinstance(v, (Table, AoT, Whitespace)) for _, v in table.value.body
not isinstance(v, (Table, AoT, Whitespace, Null))
for _, v in table.value.body
)
and not key.is_dotted()
):
Expand Down

0 comments on commit f5b1cdc

Please sign in to comment.