Skip to content

Add FormatOptions for configurable canonical formatting#223

Merged
dimbleby merged 1 commit into
mainfrom
format-options
Jul 19, 2026
Merged

Add FormatOptions for configurable canonical formatting#223
dimbleby merged 1 commit into
mainfrom
format-options

Conversation

@dimbleby

Copy link
Copy Markdown
Owner

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

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
dimbleby enabled auto-merge (rebase) July 19, 2026 11:52
@dimbleby
dimbleby merged commit 2b4d5b2 into main Jul 19, 2026
11 checks passed
@dimbleby
dimbleby deleted the format-options branch July 19, 2026 11:52
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.

1 participant