Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docarray/utils/_internal/_typing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Any, ForwardRef, Optional

from typing_extensions import get_origin
from typing_inspect import get_args, is_typevar, is_union_type
Expand Down Expand Up @@ -46,6 +46,12 @@ def safe_issubclass(x: type, a_tuple: type) -> bool:
:return: A boolean value - 'True' if 'x' is a subclass of 'A_tuple', 'False' otherwise.
Note that if the origin of 'x' is a list or tuple, the function immediately returns 'False'.
"""
if (get_origin(x) in (list, tuple, dict, set)) or is_typevar(x) or x == ID:
if (
(get_origin(x) in (list, tuple, dict, set))
or is_typevar(x)
or (type(x) == ForwardRef)
or is_typevar(x)
or x == ID
):
return False
return issubclass(x, a_tuple)
8 changes: 8 additions & 0 deletions tests/units/array/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,11 @@ def test_validate_list_dict():
'http://url.com/foo_0.png',
'http://url.com/foo_1.png',
]


def test_legacy_doc():
from docarray.documents.legacy import LegacyDocument

newDoc = LegacyDocument()
da = DocList[LegacyDocument]([newDoc])
da.summary()