Skip to content

Nesting a Table inside an InlineTable is accepted #531

@pouax

Description

@pouax

Hi,

I noticed tomlkit accepts appending a Table within an InlineTable, which isn't allowed in the toml format.

The following code does that:

import tomlkit

t = tomlkit.table()
t.append("a", 1)

it = tomlkit.inline_table()
it.append("table", t)

d = tomlkit.document()
d.append("inline_table", it)

with open("output.toml", "w") as f:
    tomlkit.dump(d, f)

which results in the following invalid toml file:

inline_table = {table = a = 1
}

Maybe tomlkit should raise an error when this happen, instead of writing invalid toml ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions