Skip to content

fix: keep docstring-only Python chunks valid - #12346

Open
Elonon901001 wants to merge 1 commit into
deepset-ai:mainfrom
Elonon901001:fix/python-code-splitter-docstring-only
Open

fix: keep docstring-only Python chunks valid#12346
Elonon901001 wants to merge 1 commit into
deepset-ai:mainfrom
Elonon901001:fix/python-code-splitter-docstring-only

Conversation

@Elonon901001

Copy link
Copy Markdown

Summary

Fixes #12330.

When strip_docstrings=True removes the only statement in a function or class, keep the generated chunk valid by inserting an indented pass. Add a regression test that parses docstring-only functions and classes with ast.parse, plus the required release note.

Validation

  • hatch run test:unit --no-cov test/components/preprocessors/test_python_code_splitter.py -q — 71 passed.
  • git diff --check

I used an AI assistant to help prepare this PR, reviewed the changes, and ran the relevant tests.

@Elonon901001
Elonon901001 requested a review from a team as a code owner August 14, 2026 09:20
@Elonon901001
Elonon901001 requested review from julian-risch and removed request for a team August 14, 2026 09:20
@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

@Elonon901001 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @Elonon901001, thanks for your interest in contributing to Haystack! 🙏

⚠️ Issue #12330 is already being addressed by open pull request(s) #12331. Before opening a PR for an issue, please check whether a PR is already linked to it, and consider contributing to the existing PR instead. We may close duplicate PRs to keep the review queue manageable.

This is an automated message to help us keep the review queue healthy.

@CLAassistant

CLAassistant commented Aug 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @Elonon901001, thanks a lot for your contribution! 🙏

We noticed that the Contributor License Agreement (CLA) check (license/cla) hasn't passed yet, so we've temporarily moved this PR to draft and paused the review assignment.

To get your PR reviewed, please sign the CLA via the link in the license/cla check below (or in the CLA bot comment). As soon as the check turns green, this PR will automatically be marked ready for review again and a reviewer will be re-assigned.

@HaystackBot
HaystackBot removed the request for review from julian-risch August 14, 2026 10:38
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Aug 14, 2026
@HaystackBot
HaystackBot marked this pull request as draft August 14, 2026 10:38
@HaystackBot
HaystackBot marked this pull request as ready for review August 14, 2026 14:37
@HaystackBot

Copy link
Copy Markdown
Contributor

Thanks for signing the CLA, @Elonon901001! 🎉 This PR is now ready for review again and the reviewer has been re-assigned.

@HaystackBot HaystackBot removed the cla-pending PR is in draft until the contributor signs the CLA label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PythonCodeSplitter with strip_docstrings=True emits invalid Python for docstring-only function/method/class bodies

3 participants