|
16 | 16 |
|
17 | 17 | from pydantic import parse_obj_as
|
18 | 18 | from typing_extensions import SupportsIndex
|
19 |
| -from typing_inspect import is_union_type, is_typevar |
| 19 | +from typing_inspect import is_typevar, is_union_type |
20 | 20 |
|
21 | 21 | from docarray.array.any_array import AnyDocArray
|
22 | 22 | from docarray.array.doc_list.io import IOMixinDocList
|
23 | 23 | from docarray.array.doc_list.pushpull import PushPullMixin
|
24 | 24 | from docarray.array.list_advance_indexing import IndexIterType, ListAdvancedIndexing
|
25 |
| -from docarray.base_doc import AnyDoc, BaseDoc |
| 25 | +from docarray.base_doc import AnyDoc |
| 26 | +from docarray.base_doc.doc import BaseDocWithoutId |
26 | 27 | from docarray.typing import NdArray
|
27 | 28 | from docarray.utils._internal.pydantic import is_pydantic_v2
|
28 | 29 |
|
|
40 | 41 | from docarray.typing.tensor.abstract_tensor import AbstractTensor
|
41 | 42 |
|
42 | 43 | T = TypeVar('T', bound='DocList')
|
43 |
| -T_doc = TypeVar('T_doc', bound=BaseDoc) |
| 44 | +T_doc = TypeVar('T_doc', bound=BaseDocWithoutId) |
44 | 45 |
|
45 | 46 |
|
46 | 47 | class DocList(
|
@@ -120,7 +121,7 @@ class Image(BaseDoc):
|
120 | 121 |
|
121 | 122 | """
|
122 | 123 |
|
123 |
| - doc_type: Type[BaseDoc] = AnyDoc |
| 124 | + doc_type: Type[BaseDocWithoutId] = AnyDoc |
124 | 125 |
|
125 | 126 | def __init__(
|
126 | 127 | self,
|
@@ -229,7 +230,7 @@ def __class_getitem__(cls, item: Union[Type[BaseDoc], TypeVar, str]):
|
229 | 230 | not is_union_type(field_type)
|
230 | 231 | and is_field_required
|
231 | 232 | and isinstance(field_type, type)
|
232 |
| - and safe_issubclass(field_type, BaseDoc) |
| 233 | + and safe_issubclass(field_type, BaseDocWithoutId) |
233 | 234 | ):
|
234 | 235 | # calling __class_getitem__ ourselves is a hack otherwise mypy complain
|
235 | 236 | # most likely a bug in mypy though
|
@@ -273,7 +274,7 @@ def to_doc_vec(
|
273 | 274 | @classmethod
|
274 | 275 | def _docarray_validate(
|
275 | 276 | cls: Type[T],
|
276 |
| - value: Union[T, Iterable[BaseDoc]], |
| 277 | + value: Union[T, Iterable[BaseDocWithoutId]], |
277 | 278 | ):
|
278 | 279 | from docarray.array.doc_vec.doc_vec import DocVec
|
279 | 280 |
|
@@ -333,9 +334,9 @@ def __getitem__(self, item):
|
333 | 334 | return super().__getitem__(item)
|
334 | 335 |
|
335 | 336 | @classmethod
|
336 |
| - def __class_getitem__(cls, item: Union[Type[BaseDoc], TypeVar, str]): |
| 337 | + def __class_getitem__(cls, item: Union[Type[BaseDocWithoutId], TypeVar, str]): |
337 | 338 |
|
338 |
| - if isinstance(item, type) and safe_issubclass(item, BaseDoc): |
| 339 | + if isinstance(item, type) and safe_issubclass(item, BaseDocWithoutId): |
339 | 340 | return AnyDocArray.__class_getitem__.__func__(cls, item) # type: ignore
|
340 | 341 | if (
|
341 | 342 | isinstance(item, object)
|
|
0 commit comments