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
{{ message }}
Repository navigation
Empty table dumped when number of subtables > 1 #377
import tomlkit
doc = tomlkit.document()
def add_table(parent, name):
parent.add(name, tomlkit.table())
return parent[name]
root = add_table(doc, 'root')
first = add_table(root, "first")
print(">>> WITH A SINGLE TABLE:")
print(tomlkit.dumps(doc))
print()
second = add_table(root, "second")
print(">>> WITH A DOUBLE TABLE:")
print(tomlkit.dumps(doc))
You get:
>>> WITH A SINGLE TABLE:
[root.first]
>>> WITH A DOUBLE TABLE:
[root]
[root.first]
[root.second]
Notice that in the second example, we get an empty [root] table, whereas in the first case we do not. In both cases, I would not expect the table to be shown (and perhaps, none of the tables should be shown...).
Is this behaviour expected, and the intended behaviour of tomlkit
Is there a way to define a table which should not be shown if it remains empty?
Activity
fix: Empty table dumped when number of subtables > 1
fix: Empty table dumped when number of subtables > 1 (#378)
pelson commentedon Aug 15, 2024
Thanks for the quick fix! 👍