From d55410fe6de72235126166898eb1a6c150a19072 Mon Sep 17 00:00:00 2001 From: venti <1308199824@qq.com> Date: Sat, 30 May 2026 16:39:08 +0800 Subject: [PATCH] fix: add missing return type hints on generator functions in text_utils.py (fixes #2330) --- packages/graphrag/graphrag/query/llm/text_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/graphrag/graphrag/query/llm/text_utils.py b/packages/graphrag/graphrag/query/llm/text_utils.py index d36aaed70f..bc39a984e7 100644 --- a/packages/graphrag/graphrag/query/llm/text_utils.py +++ b/packages/graphrag/graphrag/query/llm/text_utils.py @@ -17,7 +17,7 @@ logger = logging.getLogger(__name__) -def batched(iterable: Iterator, n: int): +def batched(iterable: Iterator, n: int) -> Iterator[tuple]: """ Batch data into tuples of length n. The last batch may be shorter. @@ -32,7 +32,7 @@ def batched(iterable: Iterator, n: int): yield batch -def chunk_text(text: str, max_tokens: int, tokenizer: Tokenizer | None = None): +def chunk_text(text: str, max_tokens: int, tokenizer: Tokenizer | None = None) -> Iterator[str]: """Chunk text by token length.""" if tokenizer is None: tokenizer = get_tokenizer()