Prefix every line of a multiline comment with ##511
Merged
frostming merged 1 commit intoJun 13, 2026
Conversation
Contributor
|
We hope that comments will always be single-line, and multi-line comments should be rejected, otherwise it will cause potential problems, such as: a = 1doc["a"].comment("line1\nline2")will produce: a = 1 # line1
#line2The second line should not belong to the table item any more. So, the right approach is: doc["a"].comment("line1")
doc.append(comment("line2"))Losing some flexibility, the code can more clearly reflect the actual structure. |
comment() only prepended '# ' to the whole string, so a value with embedded newlines rendered the second line onward without a '#' and produced invalid TOML. Prefix each line individually (bare '#' for empty lines). Fixes python-poetry#449.
27a79be to
b7ab6bc
Compare
frostming
approved these changes
Jun 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #449.
comment("line one\nline two")only prepended#to the whole string, so every line after the first was emitted without a#and the document no longer re-parsed:comment()now prefixes each line individually (a bare#for empty lines), so a multiline comment renders as a valid block of comment lines and round-trips. Single-line comments are unchanged.