[refactor] Introduce a TruncationBudget for assertion truncation#14652
Merged
Pierre-Sassoulas merged 2 commits intoJun 28, 2026
Merged
Conversation
Member
Author
|
@bluetech what do you think ? |
bluetech
approved these changes
Jun 28, 2026
bluetech
left a comment
Member
There was a problem hiding this comment.
I think it's a good idea to combine these to a type 👍
Comment on lines
+19
to
+20
| Constructed keyword-only so the two limits can never be silently | ||
| swapped at a call site. |
Member
There was a problem hiding this comment.
I'd remove this comment, I don't think it needs to be explained.
Comment on lines
+31
to
+32
| The budget carries the ``truncation_limit_lines`` / ``truncation_limit_chars`` | ||
| ini values verbatim, where ``0`` means the matching dimension is unbounded. |
Member
There was a problem hiding this comment.
I'd remove this sentence, duplicates the TruncationBudget docstring
Bundle the (max_lines, max_chars) pair that the truncation machinery passes around into a small frozen, keyword-only TruncationBudget. _get_truncation_parameters now returns (should_truncate, budget) and _truncate_explanation takes the budget directly. Keyword-only construction means the two limits can never be silently swapped at a call site. The budget carries the truncation_limit_lines / truncation_limit_chars ini values verbatim — positive bounds the dimension, 0 leaves it unbounded — so there is no extra sentinel translation. Pure refactor: truncation behaviour, footer wording and hidden-line count are unchanged.
Drop the keyword-only rationale from TruncationBudget and the verbatim ini-values sentence from _get_truncation_parameters; both restated info already carried by the TruncationBudget docstring.
3da7181 to
6bde1b2
Compare
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.
Proposal of refactor prior to #14523 where a lot of truncation budget will be passed around in assertion generator.
Bundle the (max_lines, max_chars) pair that the truncation machinery passes around into a small frozen, keyword-only TruncationBudget. _get_truncation_parameters now returns (should_truncate, budget) and _truncate_explanation takes the budget directly. Keyword-only construction means the two limits can never be silently swapped at a call site.
The budget carries the truncation_limit_lines / truncation_limit_chars ini values verbatim — positive bounds the dimension, 0 leaves it unbounded — so there is no extra sentinel translation. Pure refactor: truncation behaviour, footer wording and hidden-line count are unchanged.