Add FormatOptions for configurable canonical formatting#223
Merged
Conversation
format() previously hard-coded its canonical layout: one space before EOL comments, two-space nested indent, and an always-present multiline trailing comma. FormatOptions(normalize_comments=, indent=, eol_comment_spaces=, multiline_trailing_comma=) makes each of these configurable while keeping the current behaviour as the default. The old comments= keyword is deprecated in favour of FormatOptions(normalize_comments=...); passing both raises ValueError. Comma-first items that carry a comment on both sides of the comma no longer lose one: both are kept, the first on the item's own row and any further ones on indented lines below it. Array.format() and Container.format(), when called on a nested array or inline table directly, now preserve its existing closing-bracket column as the base indent instead of resetting it to 0 (matching set_multiline()'s existing behaviour), via a new shared format_inline_root() helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2a175df4-1a79-43fd-9c56-014aaefa9058
dimbleby
enabled auto-merge (rebase)
July 19, 2026 11:52
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.
format() previously hard-coded its canonical layout: one space before EOL comments, two-space nested indent, and an always-present multiline trailing comma. FormatOptions(normalize_comments=, indent=, eol_comment_spaces=, multiline_trailing_comma=) makes each of these configurable while keeping the current behaviour as the default. The old comments= keyword is deprecated in favour of
FormatOptions(normalize_comments=...); passing both raises ValueError.
Comma-first items that carry a comment on both sides of the comma no longer lose one: both are kept, the first on the item's own row and any further ones on indented lines below it.
Array.format() and Container.format(), when called on a nested array or inline table directly, now preserve its existing closing-bracket column as the base indent instead of resetting it to 0 (matching set_multiline()'s existing behaviour), via a new shared format_inline_root() helper.
Copilot-Session: 2a175df4-1a79-43fd-9c56-014aaefa9058