Skip to content

reject a comment containing line breaks in Item.comment and add_line#544

Merged
frostming merged 1 commit into
python-poetry:masterfrom
netliomax25-code:multiline-comment-prefix
Jul 14, 2026
Merged

reject a comment containing line breaks in Item.comment and add_line#544
frostming merged 1 commit into
python-poetry:masterfrom
netliomax25-code:multiline-comment-prefix

Conversation

@netliomax25-code

@netliomax25-code netliomax25-code commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  1. Item.comment() and Array.add_line(comment=...) accepted a comment containing an embedded newline and rendered everything after the first line without a #, so the output no longer re-parses (tomlkit and tomllib both reject it).
  2. Per review these two APIs are single-line only, so a comment containing a line break now raises ValueError up front instead of being reformatted; the item is left unmodified when it raises.
  3. Single-line comment behavior is unchanged. Tests cover both rejection paths; full suite passes.

Agent Drafting Metadata

  • Agent:
  • Model:
  • Notes:

@netliomax25-code

Copy link
Copy Markdown
Contributor Author

any update?

@frostming

Copy link
Copy Markdown
Contributor

They are different thing, add_line() and item.comment() are expected to accept single line comment ONLY. In case of string containing line breaks, you should reject it.

@netliomax25-code netliomax25-code force-pushed the multiline-comment-prefix branch from 8eacf5b to 624bb4c Compare July 14, 2026 08:12
@netliomax25-code netliomax25-code changed the title prefix every line of a multiline comment in Item.comment and add_line reject a comment containing line breaks in Item.comment and add_line Jul 14, 2026
@netliomax25-code

Copy link
Copy Markdown
Contributor Author

Makes sense, reworked it that way:

  1. Item.comment() and add_line(comment=...) now raise ValueError when the comment contains a line break, instead of trying to reformat it.
  2. Single-line behavior is unchanged; tests updated to check the rejection and the full suite still passes.

Updated the title and description to match.

@frostming frostming merged commit 21a4942 into python-poetry:master Jul 14, 2026
25 checks passed
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.

2 participants