Summary
The two generator functions in packages/graphrag/graphrag/query/llm/text_utils.py are missing return type annotations:
batched(iterable: Iterator, n: int) — yields tuple, return type not declared
chunk_text(text: str, max_tokens: int, tokenizer: Tokenizer | None = None) — yields str, return type not declared
Iterator is already imported from collections.abc in this file, so no new imports are needed.
Proposed Fix
Add -> Iterator[tuple] and -> Iterator[str] to the respective signatures. This improves downstream type safety for static analysis tools (mypy, pyright) and is consistent with the annotation style of try_parse_json_object in the same file.
Notes
- Annotation-only change, zero runtime impact
- Verified locally with
mypy --ignore-missing-imports
Summary
The two generator functions in
packages/graphrag/graphrag/query/llm/text_utils.pyare missing return type annotations:batched(iterable: Iterator, n: int)— yieldstuple, return type not declaredchunk_text(text: str, max_tokens: int, tokenizer: Tokenizer | None = None)— yieldsstr, return type not declaredIteratoris already imported fromcollections.abcin this file, so no new imports are needed.Proposed Fix
Add
-> Iterator[tuple]and-> Iterator[str]to the respective signatures. This improves downstream type safety for static analysis tools (mypy,pyright) and is consistent with the annotation style oftry_parse_json_objectin the same file.Notes
mypy --ignore-missing-imports