fix: keep statements that share a line in one PythonCodeSplitter chunk #13752
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 310 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.343
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #13752"
general
weight: 0.35
its-amann
Related Issues
Proposed Changes:
_extract_unitsslices every top-level node fromcursorto itsend_lineno. When a statement shares its line with the previous one (x = 1; y = 2), the previous unit already movedcursorpast that line, so the second statement became a unit with an empty source. That unit turned into an empty chunk at the end of a file, or was merged into the next chunk and set itsstart_lineto the previous line.The loop now skips a node whose last line is before
cursor, since its text is already in the previous unit. Only simple statements can follow a;, so this covers the catch-all statement branch and import blocks (x = 1; import os).How did you test it?
test_statements_sharing_a_line_stay_in_one_chunk(two cases: the shared line at the end of the file, and before a function). Both fail onmainand pass with the fix.pytest test/components/preprocessors/test_python_code_splitter.py: 87 passed.ruff checkandruff format --checkon the changed files pass.hatch run test:unitsuite or mypy (hatch isn't installed on this machine; I used a plain venv).Notes for the reviewer
Chunk content is unchanged for these inputs; only the empty chunk disappears and
start_lineof the following chunk is correct again.This PR was fully generated with an AI assistant (Claude Code). I have reviewed the changes and run the relevant tests.
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.🤖 Generated with Claude Code