Tighten _merge_picture_chunks type annotations

Restore the typing the merge logic carried inline before extraction:
text_chunks: list[Chunk], existing_picture_data: dict[str, bytes] | None,
-> list[Chunk], and first_pos(c: Chunk) -> int.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yiorgis Gozadinos 2026-06-23 08:56:51 +03:00
parent c59f88bcd6
commit 141e288b83
No known key found for this signature in database

View file

@ -169,11 +169,11 @@ async def convert(
def _merge_picture_chunks(
docling_document,
text_chunks: list,
docling_document: "DoclingDocument",
text_chunks: list[Chunk],
document_id: str | None,
existing_picture_data: dict | None,
) -> list:
existing_picture_data: dict[str, bytes] | None,
) -> list[Chunk]:
picture_chunks = build_picture_chunks(
docling_document,
document_id=document_id,
@ -190,7 +190,7 @@ def _merge_picture_chunks(
for pos, (item, _level) in enumerate(docling_document.iterate_items())
}
def first_pos(c):
def first_pos(c: Chunk) -> int:
refs = (c.metadata or {}).get("doc_item_refs") or []
return positions.get(refs[0], len(positions)) if refs else len(positions)