Repository navigation
fix: keep code on the same line as a docstring in PythonCodeSplitter - #13309
Closed
rautaditya2606 wants to merge 1 commit into
Closed
rautaditya2606 wants to merge 1 commit into
rautaditya2606 wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Contributor
|
@rautaditya2606 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
rautaditya2606
marked this pull request as ready for review
October 17, 2026 15:47
rautaditya2606
requested review from
bogdankostic
and
a balanced review from Copilot
and removed request for
a team
October 17, 2026 15:47
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
4 of 5 tasks
7 tasks done
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.
Related Issues
Proposed Changes:
_strip_docstringremoves the docstring by dropping whole lines, so anything sharing a line with it was dropped too ("""Docs."""; return 5lost thereturn 5).Now it checks the text before and after the docstring on its lines. If there's other code there, it leaves the docstring in place, the same way it already does when the docstring sits on the
defline. A trailing comment (like# noqa: D400) doesn't count and is still dropped with the docstring, as before. The column offsets fromastare UTF-8 byte offsets, so the check slices the encoded line.How did you test it?
Added unit tests in
test_python_code_splitter.py: three cases where code shares the docstring's line (function, multi-line docstring, class), and one for the trailing comment. The three code-loss tests fail without the change and pass with it. The trailing comment test passes either way, it just pins the existing behavior.I ran
hatch run test:unit test/components/preprocessors/,hatch run fmtandhatch run test:types, all clean. I only ran them on Python 3.13, not 3.11.Notes for the reviewer
The check is small and sits right after the existing "docstring shares a line with the def" guard. I chose to keep the docstring in the chunk (and out of
meta["docstrings"]) in this case instead of splitting the line, to keep the line-based stripping simple.This PR was generated with an AI assistant (Claude Code). The relevant tests,
hatch run fmtandhatch run test:typeswere run.Checklist
fix:hatch run fmtandhatch run test:typesand fixed any issue.🤖 Generated with Claude Code