Skip to content

Inconsistent newline behavior based on order of insertion #387

Closed

Description

@hcording

I stumbled over this behavior today:

table().add("a", table()).add("y", 3.2).as_string()
'y = 3.2\n[a]\n'

table().add("y", 3.2).add("a", table()).as_string()
'y = 3.2\n\n[a]\n'

I wouldn't expect the results to differ, because in both cases the literal is inserted above the table. It seems that the second result is what should be always produced, because it conforms with the current practice of always separating tables from previous content by an additional newline. But this seems to break when inserting a literal over the first table in the document, if I see that correctly.

tomlkit 0.13.2
python 3.12.7
linux

Activity

  1. self-assigned this
    on Jun 5, 2025
  2. added a commit that references this issue on Jun 5, 2025
    13af828
  3. added a commit that references this issue on Jun 5, 2025
    d4e1ecd
  4. added a commit that references this issue on Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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