Skip to content

tomlkit does not serialize some empty arrays and dictionaries #553

Description

@dimbleby
#!/usr/bin/env python3

import tomlkit


doc = tomlkit.loads("""
x.y.z = 1

[[a]]
x = 1
""")

doc["a"].pop()
doc["x"]["y"].pop("z")

print(f"{doc=}")

rendered = tomlkit.dumps(doc)
print(f"{rendered=}")

result

doc={'x': {'y': {}}, 'a': []}
rendered='\n\n'

Two newlines is not a good TOML representation of that dictionary

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions