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

fix: don't add header when removing items from a supertable #219

Merged
merged 1 commit into from Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/test_toml_document.py
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
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