You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A regex pins a phrase inside a # comment, so rewrapping that comment fails the test with a false explanation #1732
Found while closing #1714, which routed the contract assertions that pin a sentence through a whitespace-collapsing reader. One sibling in the same class is left unfixed there, because collapsing whitespace cannot fix it.
The shape
scripts/tests/test_pr_review.py:3395-3403 pins a 60-character prose phrase against the raw source of scripts/pr_review.py:
source=Path(pr_review.__file__).read_text(encoding="utf-8")
stated=re.search(
r"the output is regular: (\d+) headings, (\d+) summaries and (\d+) labels", source
)
ifstatedisNone:
self.fail("the comment stating the vetted list sizes is no longer in the source")
The phrase lives in a # comment at scripts/pr_review.py:441, currently 92 of the 100 characters pyproject.toml permits.
Why it matters
Adding one word earlier in that comment rewraps it. The phrase then spans two lines, the regex stops matching, and the test takes the if stated is None branch and fails with the comment stating the vetted list sizes is no longer in the source. That message asserts the comment was deleted when it was only rewrapped, so the failure actively misdirects whoever reads it.
This is the same failure mode #1714 describes, and it is worse than the instances that issue named, because the two that were genuinely exposed there fail with a plain assertIn mismatch while this one fails with a false explanation.
flowed_text collapses whitespace runs to single spaces. A rewrapped # comment does not merely gain a newline, it gains a comment marker:
# ... the output is regular: 10 headings, 10
# summaries and 4 labels.
collapses to ... the output is regular: 10 headings, 10 # summaries and 4 labels., so the needle still does not match. The interleaved # is the part collapsing cannot remove.
The fix
A reader that strips a leading comment marker from each line before collapsing, applied to the assertions that pin prose sitting inside source comments rather than inside a docstring. scripts/tests/test_pr_review.py is the only file known to hold one today, and the sweep that found this one covered every test and validator in the tree, so any second instance would be newly written rather than already present.
Not reproducible as a failing test today
No current test fails. The trigger is a future edit to that comment, and the evidence is the regex shape plus the comment sitting 8 characters under the wrap limit.
Two more siblings in the same class, found by the second review round on the #1714 branch. Both pin a whitespace-bearing needle against wrappable Python code rather than against a comment, so neither is fixed by the comment-marker reader this issue asks for, and neither is fixed by collapsing whitespace either.
scripts/tests/test_pr_review.py:5734 anchors on two spaces of code:
source.split("delays = [")[1]
Adding a type annotation, so the source reads delays: list[int] = [15, ...], makes split return a single element and [1] raise IndexError. The test then errors with a traceback rather than the named failure its sibling at 3405-3406 is careful to produce, so the reader is told nothing about what actually changed.
scripts/tests/test_pr_review.py:5486 pins "n in blob" against a 96-character comprehension, one word short of where the formatter breaks the line. A rewrap splits the needle and the assertion fails claiming the byte-matching behaviour is gone when only the line moved.
Both are latent in the same way this issue's subject is: no test fails today, and the trigger is a future edit. Recording them here rather than filing separately, since the fix is one decision about how these assertions should read their source rather than three.
Activity
ptr727 commentedon Sep 21, 2026
Two more siblings in the same class, found by the second review round on the #1714 branch. Both pin a whitespace-bearing needle against wrappable Python code rather than against a comment, so neither is fixed by the comment-marker reader this issue asks for, and neither is fixed by collapsing whitespace either.
scripts/tests/test_pr_review.py:5734anchors on two spaces of code:Adding a type annotation, so the source reads
delays: list[int] = [15, ...], makessplitreturn a single element and[1]raiseIndexError. The test then errors with a traceback rather than the named failure its sibling at 3405-3406 is careful to produce, so the reader is told nothing about what actually changed.scripts/tests/test_pr_review.py:5486pins"n in blob"against a 96-character comprehension, one word short of where the formatter breaks the line. A rewrap splits the needle and the assertion fails claiming the byte-matching behaviour is gone when only the line moved.Both are latent in the same way this issue's subject is: no test fails today, and the trigger is a future edit. Recording them here rather than filing separately, since the fix is one decision about how these assertions should read their source rather than three.
Collapse Whitespace Before Pinning a Sentence in the Docstring Tests (#…
Promote the Whitespace-Collapsing Docstring Assertions to Main (#1734)
Harden the Source-Pinning Assertions in test_pr_review.py (#2697)