|
2 | 2 | # |
3 | 3 | # SPDX-License-Identifier: Apache-2.0 |
4 | 4 |
|
| 5 | +from collections.abc import Callable |
5 | 6 | from copy import deepcopy |
6 | | -from typing import Any, Callable, Literal, Optional |
| 7 | +from typing import Any, Literal |
7 | 8 |
|
8 | 9 | from haystack import Document, component, logging |
9 | 10 | from haystack.core.serialization import default_from_dict, default_to_dict |
@@ -59,7 +60,7 @@ def __init__( |
59 | 60 | split_overlap: int = 200, |
60 | 61 | split_threshold: int = 0, |
61 | 62 | respect_sentence_boundary: bool = False, |
62 | | - splitting_function: Optional[Callable] = None, |
| 63 | + splitting_function: Callable | None = None, |
63 | 64 | granularity: Literal["coarse", "fine"] = "coarse", |
64 | 65 | ): |
65 | 66 | """ |
@@ -406,7 +407,7 @@ def _create_docs_from_splits( |
406 | 407 | """ |
407 | 408 | documents: list[Document] = [] |
408 | 409 |
|
409 | | - for i, (txt, split_idx) in enumerate(zip(text_splits, splits_start_idxs)): |
| 410 | + for i, (txt, split_idx) in enumerate(zip(text_splits, splits_start_idxs, strict=True)): |
410 | 411 | copied_meta = deepcopy(meta) |
411 | 412 | copied_meta["page_number"] = splits_pages[i] |
412 | 413 | copied_meta["split_id"] = i |
|
0 commit comments