Fix inline table separator after append#477
Open
cyliu0 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 -qpython3 -m pytest tests -qgit diff --check