Skip to content

Fix inline table separator after append#477

Merged
frostming merged 2 commits into
python-poetry:masterfrom
cyliu0:fix-inline-table-append-separator
May 27, 2026
Merged

Fix inline table separator after append#477
frostming merged 2 commits into
python-poetry:masterfrom
cyliu0:fix-inline-table-append-separator

Conversation

@cyliu0
Copy link
Copy Markdown
Contributor

@cyliu0 cyliu0 commented May 18, 2026

Summary

Fix inline table serialization after appending a new key to a parsed inline table that already preserved explicit comma tokens.

The serializer now tracks whether an emitted key still needs a separator. When a later mutation adds a key without an explicit comma token, as_string() inserts the missing comma before rendering the next key.

Fixes #476.

Tests

  • python3 -m pytest tests/test_items.py::test_appending_to_parsed_inline_table_preserves_separator tests/test_items.py::test_deleting_inline_table_element_does_not_leave_trailing_separator tests/test_items.py::test_deleting_inline_table_element_does_not_leave_trailing_separator2 tests/test_items.py::test_items_can_be_appended_to_and_removed_from_an_inline_table -q
  • python3 -m pytest tests -q
  • git diff --check

@cyliu0
Copy link
Copy Markdown
Contributor Author

cyliu0 commented May 27, 2026

Hi @frostming, could you please take a look at this PR when you have a chance? It fixes a 0.15.0 regression where appending a key to a parsed inline table can serialize invalid TOML. The PR includes a regression test, and the full test suite passes locally (968 passed).

@frostming frostming merged commit 1d49987 into python-poetry:master May 27, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.15.0 serializes invalid TOML when appending to a parsed inline table

2 participants