Skip to content

Fix regression in String.from_raw and improve documentation - #658

Merged
frostming merged 2 commits into
python-poetry:masterfrom
sattlerc:issue655
Oct 27, 2026
Merged

frostming merged 2 commits into
python-poetry:masterfrom
sattlerc:issue655

Conversation

@sattlerc

Copy link
Copy Markdown
Contributor

This PR streamlines the control flow of String.from_raw, fixing #655, and improves the documentation of string(..., escape=False).

@Wkhanex Wkhanex left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted validation at 386786c7a48c on Python 3.12.14: I checked basic/literal and single/multiline strings with backslashes, a tab, Unicode text, and ordinary text. With escaping enabled, all 16 combinations round-tripped through tomllib with their input value intact. For multiline strings beginning with one or two LFs, I separately verified that escape=False emits the supplied body verbatim, while the default mode adds the trim-protection newline. The 79 string-focused API/item tests passed.

That separation is the behavior I would preserve in regression coverage: verbatim mode may intentionally give a parsed value different from the raw body because TOML trims an opening newline. It should not silently gain the extra newline needed by the default value-preserving mode.

@dimbleby

Copy link
Copy Markdown
Contributor

Explain why not #656

@sattlerc

Copy link
Copy Markdown
Contributor Author

Explain why not #656

In contrast to #656, this PR:

  • cleans up the control flow of String.from_raw, gating all escape actions under a single if escape check,
  • clarifies the documentation of the escape flag,
  • was written by a human.

Note that the situation is still not ideal, see #655 (comment). A proper solution would require an API change, but that's beyond the scope of this bug fix.

@frostming

Copy link
Copy Markdown
Contributor

@dimbleby I'm tired of this—just one week, 20 new PRs. How can this be mitigated? Any good suggestion?

@dimbleby

dimbleby commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

You have my sympathy. I see a similar influx of mixed quality AI pull requests in poetry: it is a blessing and a curse.

(Ack that sattlerc explicitly says this PR is human-written, I am talking about the larger picture rather than this one specifically).

The bots are pretty good at following instructions, so it is likely worth putting some instructions in the repository somewhere - AGENTS.md or whatever - saying what sort of AI contributions are acceptable to you.

If you can identify what it is you don't like about what they're doing today - write that down and tell them not to do it. Eg text like "before contributing a pull request you must check for open pull requests already fixing the same thing" would likely discourage most of the duplicates.

You could even write that you didn't want any AI contributions at all, though I think that would be a shame - there are some genuine bugs and fixes being contributed. But lots of projects are doing that, you would not be alone.

I expect your time is limited, but in principle another answer would be to review and merge more. Once a bug is fixed - that should stop the bots from sending fixes for it.

@frostming frostming linked an issue Oct 27, 2026 that may be closed by this pull request
@frostming
frostming merged commit 10fbd37 into python-poetry:master Oct 27, 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.

Regression: impossible to dump multiline strings with leading newline

4 participants