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
rewrite new toml-data will has a new whitespace line #352
I'm not sure if this is a bug, so I checked the source code.
in file tomlkit/container.py, line 703 with function _replace_at , it will add a whitespace-line where there is not has whitespace-line.
how check ? the end of tomlkit/container.py
defends_with_whitespace(it: Any) ->bool:
"""Returns ``True`` if the given item ``it`` is a ``Table`` or ``AoT`` object ending with a ``Whitespace``. """return (
isinstance(it, Table) andisinstance(it.value._previous_item(), Whitespace)
) or (isinstance(it, AoT) andlen(it) >0andisinstance(it[-1], Whitespace))
ends_with_whitespace only check last and current without sub-tree.
Should subdata be checked ?
Reacted by vinicius, Benjamin Lowry, Jiang Taotao and Nathan McDougall
Activity
`tomlkit` may omit the newline: workaround limitations with regexes
dimbleby commentedon Jun 6, 2026
Does not reproduce today
kdeldycke commentedon Jun 10, 2026
It does, even with
tomlkit0.15.0.Proof:
Which produces:
dimbleby commentedon Jun 10, 2026
oh I see - the original report provided a repro that did not actually do anything! So indeed nothing changed when I "executed" it...