Skip to content

Preserve array separators when appending after standalone comments - #671

Open
vera-rubin wants to merge 1 commit into
python-poetry:masterfrom
vera-rubin:fix/array-comment-comma
Open

vera-rubin wants to merge 1 commit into
python-poetry:masterfrom
vera-rubin:fix/array-comment-comma

Conversation

@vera-rubin

Copy link
Copy Markdown

Summary

On tomlkit 0.15.1 (19edc23b0244), appending produces a = [1\n# end\n2\n]\n. TOML requires commas; expected parsed output is {"a": [1, 2]}.

import tomlkit

doc = tomlkit.parse("a = [1\n# end\n]\n")
doc["a"].append(2)
print(tomlkit.dumps(doc), end="")

We now look past standalone comments for the preceding value or separator, preserving indentation and trailing comma style.

We tested the regression cases and the full existing suite, and checked the saved document with tomllib.

Agent Drafting Metadata

AI-assisted.

  • Agent: Codex
  • Model: gpt-6.1-sol
  • Notes: AI-assisted: yes, reviewed and tested as described.

Assisted-by: Codex / gpt-6.1-sol

— ChipLab

Look past standalone comment groups for the preceding value or separator while retaining the copied indentation and existing comma style.

Assisted-by: Codex / gpt-6.1-sol
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