Skip to content

fix: close Array.add_line output before the closing bracket - #585

Open
Neallin-917 wants to merge 1 commit into
python-poetry:masterfrom
Neallin-917:neallin-917-fix-array-add-line-serialization
Open

fix: close Array.add_line output before the closing bracket#585
Neallin-917 wants to merge 1 commit into
python-poetry:masterfrom
Neallin-917:neallin-917-fix-array-add-line-serialization

Conversation

@Neallin-917

Copy link
Copy Markdown

Summary

  • preserve a trailing line break for content added with Array.add_line()
  • avoid emitting a comment immediately before the closing ], which produces invalid TOML
  • add a regression test that parses the generated output

Fixes #580

Validation

  • poetry run pytest tests/test_items.py -k array_add_line -q
  • poetry run pytest -q tests (1052 passed)
  • uvx ruff@0.15.21 check tomlkit/items.py tests/test_items.py
  • poetry run python -m compileall -q tomlkit tests/test_items.py

poetry run mypy tomlkit/items.py tests/test_items.py still reports the pre-existing tomlkit/items.py:2172 annotation error.

Disclosure

AI assistance was used while preparing this contribution; I reviewed the change and ran the validation above.

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.

Array.add_line() doesn't serialize as documented (or expected) and can even produce syntactically invalid TOML

1 participant