Skip to content

Missing return type hints on generator functions in query/llm/text_utils.py #2330

@ilias-laoukili

Description

@ilias-laoukili

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions