Skip to content

Preserve line boundaries when moving array-of-tables elements - #679

Open
hakarrr wants to merge 2 commits into
python-poetry:masterfrom
hakarrr:fix-aot-insert-boundaries
Open

hakarrr wants to merge 2 commits into
python-poetry:masterfrom
hakarrr:fix-aot-insert-boundaries

Conversation

@hakarrr

@hakarrr hakarrr commented Oct 24, 2026

Copy link
Copy Markdown

Summary

Moving the last parsed array-of-tables element with pop() and insert(0, ...) can join its unterminated final value or comment to the next [[header]]. This produces invalid TOML or silently captures the next element's fields. Add a line boundary when rendering adjacent elements if neither the preceding output nor the next header's indentation supplies one. Existing whitespace and comments remain unchanged.

Eleven regression cases cover LF/CRLF input, scalar and header comments, nested tables, empty tables, and existing spacing. Eight fail without the correction. The full suite including the initialized TOML conformance corpus passes on Python 3.12.15 (1,214 tests); Python 3.10.12 has 1,213 passed and one existing skip. All pinned pre-commit hooks pass. Mypy 1.19.1 reports the same 32 existing diagnostics in seven files on unchanged master and this patch under Python 3.12, with no added diagnostics.

This does not add sorting support or change assignment behavior.

Agent Drafting Metadata

  • Agent: AI-assisted development
  • Model: Not disclosed.
  • Notes: AI assistance was used for investigation, implementation, regression tests, and this description. The reported negative control and checks were executed locally.

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