Repository navigation
fix: align PythonCodeSplitter line splits with ast - #13301
Conversation
|
@thecaptain789 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @Eryx-Z, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
str.splitlines() also breaks on form feed and other Unicode separators, but ast line numbers only use \\n / \\r\\n / \\r. Sources with a form feed then sliced units one line early. Split with io.StringIO(..., newline="") so chunks and start_line / end_line stay correct. Fixes deepset-ai#13299
d4b22fe to
7ece48c
Compare
|
Thanks for signing the CLA, @Eryx-Z! 🎉 This PR is now ready for review again and the reviewer has been re-assigned. |
|
Verified locally: the new |
anakin87
left a comment
There was a problem hiding this comment.
Thank you!
I pushed a few minor simplifications
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
Related Issues
Proposed Changes:
PythonCodeSplitterbuilt its line list withstr.splitlines(keepends=True), which also breaks on form feed and other Unicode separators.astline numbers only use\n/\r\n/\r, so a form feed shifted every later unit by one line (functions split across chunks, wrongstart_line/end_line).Split with
io.StringIO(source, newline="").readlines()so the line list matchesast.How did you test it?
Added
test_form_feed_does_not_shift_ast_line_numbersand ranTestEdgeCases.Notes for the reviewer
Suggested approach from the issue report.
Checklist
fix:.