Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Fix `comment()` producing invalid TOML for a multiline string by prefixing every line with `#`, not just the first. ([#449](https://github.com/python-poetry/tomlkit/issues/449))
- Fix the separator comma being swallowed by a trailing comment when appending a key to a multiline inline table, leaving the new key without a separator so the result no longer round-trips. ([#512](https://github.com/python-poetry/tomlkit/issues/512))
- Fix a `KeyAlreadyPresent` error when parsing or accessing an out-of-order table whose array-of-tables elements are split across the table's parts. ([#505](https://github.com/python-poetry/tomlkit/issues/505))
- Fix a stale dotted-key prefix when replacing a dotted-key table value with a plain dict, where ``fruit.apple = true`` followed by ``doc['fruit'] = {'a': 1}`` would render a ``[fruit]`` header followed by the wrongly dotted ``fruit.a = 1`` instead of ``a = 1``. ([#524](https://github.com/python-poetry/tomlkit/issues/524))

## [0.15.0] - 2026-05-10

Expand Down
12 changes: 12 additions & 0 deletions tests/test_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,18 @@ def test_serialize_table_with_dotted_key() -> None:
assert parent.as_string() == "[a]\nb.c = 1\n"


def test_replacing_dotted_key_table_clears_prefix() -> None:
"""Replacing a dotted-key table with a plain dict should not carry
over the dotted prefix to the new children (#524)."""
doc = parse("fruit.apple = true\n")
doc["fruit"] = {"a": 1}
rendered = doc.as_string()
assert rendered == "[fruit]\na = 1\n"
# Round-trip
doc2 = parse(rendered)
assert doc2["fruit"]["a"] == 1


def test_not_showing_parent_header_for_super_table() -> None:
doc = api.document()

Expand Down
1 change: 1 addition & 0 deletions tomlkit/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ def _replace_at(
new_key = SingleKey(new_key)
else: # Inherit the sep of the old key
new_key = k
new_key._dotted = False # Reset dotted heritage on full replacement

del self._map[k]
self._map[new_key] = idx
Expand Down
Loading