Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

Python 3.10 TypeError: issubclass() arg 1 must be a class #1903

Description

@daip-yxtay

Initial Checks

  • I have read and followed the docs and still think this is a bug

Description

TypeError for issubclass in python 3.10. Works in python 3.11.

I think it is due to usage of issubclass that is missed out in the following.

type_ = self._get_field_annotation(field)
if isinstance(type_, type) and issubclass(type_, AnyDocArray):
doclist_exclude_fields.append(field)

Related: #1557 #1584

Traceback (most recent call last):
  File "/.../test.py", line 12, in <module>
    item.model_dump()
  File "/.../lib/python3.10/site-packages/docarray/base_doc/doc.py", line 520, in model_dump
    return _model_dump(super())
  File "/.../lib/python3.10/site-packages/docarray/base_doc/doc.py", line 488, in _model_dump
    ) = self._exclude_doclist(exclude=exclude)
  File "/.../lib/python3.10/site-packages/docarray/base_doc/doc.py", line 329, in _exclude_doclist
    if isinstance(type_, type) and issubclass(type_, AnyDocArray):
  File "/.../lib/python3.10/abc.py", line 123, in __subclasscheck__
    return _abc_subclasscheck(cls, subclass)
TypeError: issubclass() arg 1 must be a class

Example Code

from __future__ import annotations

from docarray import BaseDoc, __version__


class Document(BaseDoc):
    list_str: list[str]


item = Document(list_str=["a", "b", "c"])
item.model_dump()

Python, DocArray & OS Version

python: 3.10
docarray: 0.40.0
platform: macOS-14.6.1-x86_64-i386-64bit

Affected Components

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions