Context
DocumentArray is a Generic but cannot be used with TypeVar. We need to handle this case as well. We need to modify the class_getitem of AnyDocumentArray.
This don't work
from docarray import DocumentArray, BaseDocument
from typing import TypeVar, List
T = TypeVar('T', bound=BaseDocument)
def f(a: DocumentArray[T]) -> DocumentArray[T]:
return a
Traceback (most recent call last):
File "scratch_3.py", line 7, in <module>
def f(a: DocumentArray[T]) -> DocumentArray[T]:
File "docarray/docarray/array/abstract_array.py", line 38, in __class_getitem__
if not issubclass(item, BaseDocument):
File "/versions/3.9.10/lib/python3.9/abc.py", line 123, in __subclasscheck__
return _abc_subclasscheck(cls, subclass)
TypeError: issubclass() arg 1 must be a class
whereas this work fine
def g(a: List[T]) -> List[T]:
return aReactions are currently unavailable
Context
DocumentArray is a Generic but cannot be used with TypeVar. We need to handle this case as well. We need to modify the class_getitem of AnyDocumentArray.
This don't work
whereas this work fine