← Back to Pull requests

fix: keep statements that share a line in one PythonCodeSplitter chunk #13752

Open
unknown opened this pull request with 310 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 14, 2026 18:03 UTC
Author

Related Issues

  • fixes #13751
  • Proposed Changes:

    _extract_units slices every top-level node from cursor to its end_lineno. When a statement shares its line with the previous one (x = 1; y = 2), the previous unit already moved cursor past 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 its start_line to 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?

  • Added 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 on main and pass with the fix.

  • pytest test/components/preprocessors/test_python_code_splitter.py: 87 passed.

  • ruff check and ruff format --check on the changed files pass.

  • I did not run the full hatch run test:unit suite 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_line of 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

  • I have read the contributors guidelines and the code of conduct.

  • I have updated the related issue with new insights and changes.

  • I have added unit tests and updated the docstrings.

  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.

  • I have documented my code.

  • I have added a release note file, following the contributors guidelines.

  • I have run pre-commit hooks and fixed any issue.
  • 🤖 Generated with Claude Code

    Diff: 310 lines (+232 / -78) across 3 files Reviewer: its-amann Review duration: 19390m
    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
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.3% (MEDIUM) · Higher = larger blast radius
    45.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.1% · Safe to merge
    24.1%