Repository navigation
Merged
Conversation
…h the shared heredoc tracker `_check_catch_all_in_loop` and `_check_single_line_delegate_positional` were the two checkers #980 deliberately left out of its `_iter_non_heredoc_lines` migration, but each docstring claimed the gap was "filed for a follow-up" when no such issue existed until this one. Routed both through the shared tracker: `_check_catch_all_in_loop` now iterates `_iter_non_heredoc_lines(text, track_heredocs=True)` instead of a raw `enumerate(text.splitlines(), 1)` -- the generator tracks heredoc delimiters independently of the function's own multi-line open/close-depth and in-string state, so the two interleave without either needing to know about the other. `_check_single_line_delegate_positional` now filters the extracted function-body string through the same generator instead of a bare `.startswith("#")` test, so a heredoc attached to a function's single real statement no longer inflates the apparent line count and blinds the needle to it. Red test first in both tests/test_scanner_shapes_source_898.py and tests/test_single_line_delegate_positional_905.py (2 failed before the fix, 1 unaffected positive control passed); all 410 tests across the two touched suites plus test_heredoc_comment_guard_980.py pass after. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…f-review The Explore reviewer caught a real regression in the previous commit: swapping _check_catch_all_in_loop's own enumerate(text.splitlines(), 1) for the shared _iter_non_heredoc_lines generator directly fixed the documented false-positive, but introduced a false negative. The generator's heredoc-open detection runs on every line it yields with no visibility into this function's own multi-line in_string state (a tracked VAR='... single-quoted string), so a `<<WORD`-shaped substring sitting inside the body of one of those tracked strings was misread as a real heredoc opener and silently swallowed every later line -- including a genuine catch-all-in-loop -- as fake heredoc body. Verified directly: running the committed (post-990) checker against a crafted script with that shape returned no offenders, while running the pre-990 (parent commit) checker against the same input correctly flagged it. Fixed by tracking heredoc delimiters inline instead of delegating to the generator -- same regexes _iter_non_heredoc_lines itself uses (_mask_arithmetic, _HEREDOC_OPEN, _in_quotes_before), but gated so detection only runs on a line that already passed this function's own in_string/comment checks, so the two states can never step on each other. Docstring and changelog fragment corrected to describe the actual approach rather than the claim the reviewer found false. Red test (test_heredoc_open_syntax_inside_the_checkers_own_tracked_ string_does_not_blind_it) confirmed failing against the prior commit; all 411 tests across the touched suites pass after this fix. Co-Authored-By: Claude Sonnet 5 <[email protected]>
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
Closes #990.
_check_catch_all_in_loopand_check_single_line_delegate_positionalin.github/scripts/check_release_tree.pywere the two checkers #980 deliberately left out of its_iter_non_heredoc_linesmigration. Each docstring claimed the gap had been "filed for a follow-up rather than fixed silently alongside the other 16," but no such issue existed until #990 itself (checked at review time via issue search, and again during the curate pass that filed #990)._check_single_line_delegate_positionalnow filters its extracted function-body string through_iter_non_heredoc_lines(body, track_heredocs=True)instead of a bare.startswith("#")test, so a heredoc attached to a function's single real statement no longer inflates the apparent line count and blinds the needle to it._check_catch_all_in_loopneeded more care. A first attempt swapped its ownenumerate(text.splitlines(), 1)loop for the shared generator directly, and that regressed in round-1 self-review: the generator's heredoc-open detection has no visibility into this function's own multi-linein_stringstate, so a<<WORD-shaped substring sitting inside a tracked quoted string was misread as a real heredoc opener and silently swallowed every later line -- including a genuine catch-all-in-loop -- as fake heredoc body. Fixed instead by tracking heredoc delimiters inline (the same regexes_iter_non_heredoc_linesitself uses:_mask_arithmetic,_HEREDOC_OPEN,_in_quotes_before), gated so detection only runs on a line that has already passed this function's own in_string/comment checks, so the two states can never step on each other.Review
Two review rounds, each a parallel Explore-reviewer + oss:auditor spawn pair:
_check_catch_all_in_loop(the in_string/heredoc-open collision described above, verified empirically with a crafted fixture) and flagged the docstring's now-false claim about the two states interleaving safely. oss:auditor reported no findings across all classes. Both findings fixed in a follow-up commit.Test plan
python3 -m pytest tests/test_scanner_shapes_source_898.py tests/test_single_line_delegate_positional_905.py tests/test_heredoc_comment_guard_980.py -q-- 411 passed.oss/assemble_changelog.py --check🤖 Generated with Claude Code
[AI-generated]