Skip to content

Commit 74c009d

Browse files
committed
docs(stdlib): add Args and Returns sections to chunker flush overrides
The Docs CI docstring quality gate [no_class_args]-equivalent check requires every documented method with typed params to have an Args section and a Returns section matching the return annotation. SentenceChunker.flush, WordChunker.flush, and ParagraphChunker.flush all took accumulated_text and returned list[str] without the sections. Add both to each override, documenting each flush's specific semantics (rstrip for sentences, whitespace-split trailing fragment for words, byte-for-byte for paragraphs). Assisted-by: Claude Code
1 parent da41a06 commit 74c009d

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

mellea/stdlib/chunking.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ def flush(self, accumulated_text: str) -> list[str]:
124124
``lstrip`` is needed here. The result is the fragment's content
125125
only, consistent with how :meth:`split` returns sentences without
126126
trailing whitespace.
127+
128+
Args:
129+
accumulated_text: The full accumulated text at stream end.
130+
131+
Returns:
132+
A single-element list containing the trailing sentence fragment
133+
with leading and trailing whitespace stripped, or an empty list
134+
when there is no fragment (all content ended in a sentence
135+
boundary or the input is empty/whitespace-only).
127136
"""
128137
if not accumulated_text:
129138
return []
@@ -177,7 +186,21 @@ def split(self, accumulated_text: str) -> list[str]:
177186
return parts
178187

179188
def flush(self, accumulated_text: str) -> list[str]:
180-
"""Return the trailing word fragment (if any) as a final chunk."""
189+
"""Return the trailing word fragment (if any) as a final chunk.
190+
191+
The trailing fragment is the text after the last whitespace run when
192+
the accumulated text does not end with whitespace. When it does end
193+
with whitespace, every word is already complete and no fragment is
194+
released.
195+
196+
Args:
197+
accumulated_text: The full accumulated text at stream end.
198+
199+
Returns:
200+
A single-element list containing the trailing word fragment, or
201+
an empty list when the input ends with whitespace (every word
202+
already complete) or is empty.
203+
"""
181204
if not accumulated_text:
182205
return []
183206
if accumulated_text[-1].isspace():
@@ -232,6 +255,14 @@ def flush(self, accumulated_text: str) -> list[str]:
232255
a paragraph (e.g. a list item or a deliberate line break), and a
233256
consumer validating paragraph content should see the fragment as
234257
it was withheld.
258+
259+
Args:
260+
accumulated_text: The full accumulated text at stream end.
261+
262+
Returns:
263+
A single-element list containing the trailing paragraph fragment
264+
byte-for-byte, or an empty list when the input ends with a
265+
paragraph boundary (``\n\n`` or more) or is empty.
235266
"""
236267
if not accumulated_text:
237268
return []

0 commit comments

Comments
 (0)