Skip to content

Commit dc9ac34

Browse files
doc(python_code_splitter): add comments for the identity preservation logic
1 parent e730f42 commit dc9ac34

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

haystack/components/preprocessors/python_code_splitter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@ def _secondary_split(self, unit: _CodeUnit, parent_doc: Document) -> list[Docume
556556
meta["secondary_split"] = True
557557
meta["secondary_split_index"] = idx
558558
meta["secondary_split_total"] = len(intermediate)
559+
560+
# Prepend the unit's qualified name as a comment to non-first pieces,
561+
# since only the first piece naturally retains the def/class signature line.
559562
content = piece.content or "" if idx == 0 else f"# {qualified_name}\n{piece.content or ''}"
560563
results.append(Document(content=content, meta=meta))
561564
return results

0 commit comments

Comments
 (0)