Adopt PEP 822 dedentation and default t-string alignment - #24
Merged
Merged
Conversation
Use exact indentation-prefix semantics while preserving interpolation support and documenting runtime differences.
Preserve exact line-ending and indentation semantics while rendering template and alignment holes without letting interpolated values alter dedentation.
Keep continuation lines directly beneath each interpolation, including nested and same-line values, so rendered output remains structurally aligned.
Adopt current lint rule names and refresh test, type-checking, formatting, and lockfile dependencies.
Remove the strip modes so dedent omits only the opening newline and preserves all remaining whitespace, matching PEP 822 quote-placement semantics.
Remove redundant global and opt-in controls so only explicit per-value noalign exceptions remain.
Fail clearly when the f-string-only wrapper reaches a t-string, avoiding ambiguous alignment precedence.
Treat spaces and tabs before the first line ending as the opener while documenting runtime divergences from PEP 822.
Protect conversion handling and column tracking across consecutive multiline values.
Keep literal parts structural so dedentation no longer requires UUID markers or regex reconstruction.
Owner
Author
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit f57c91d. Configure here.
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.
Summary
Aligns
dedent()with PEP 822 indentation and newline semantics while making multiline interpolation compose predictably across t-strings and f-strings.alignby default #10Changes
noalign, while supporting f-string alignment throughalign().textwrap.dedentcomparison, and PEP 822 reference material.Note
High Risk
This is a breaking API and whitespace contract change across all
dedent()callers, with a large refactor of core dedent/alignment logic and new error paths for malformed indentation.Overview
dedent()now follows PEP 822 indentation: exact space/tab prefixes, closing-line control of trailing newlines, andIndentationErroron incompatible whitespace-only lines. It drops the opening newline after triple quotes and removes thestripandalignkeyword arguments—other whitespace is left intact.Interpolation is reworked so literal segments are dedented before holes are filled. t-strings align multiline values by default;
{value:noalign}opts out.align()remains for f-strings andTypeErrorif used in t-strings.The README is rewritten around the new behavior and rules. Tests move to inline-snapshot and split by concern; dev tooling (ruff, basedpyright, etc.) is bumped.
Reviewed by Cursor Bugbot for commit f57c91d. Bugbot is set up for automated code reviews on this repo. Configure here.