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.

Bug: issubclass cause error in IOMixin._get_access_paths #1584

Closed

Description

@lazyhope

The issue described in #1557 still exists in IOMixin._get_access_paths, here is an example:

from typing import List
from docarray import BaseDoc, DocList

class TestDoc(BaseDoc):
    topics: List[str]

dl = DocList[TestDoc]([TestDoc(topics=["a", "b"])])
dl.to_dataframe()

Produces the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 6
      4     topics: List[str]
      5 dl = DocList[TestDoc]([TestDoc(topics=["a", "b"])])
----> 6 dl.to_dataframe()

File ~/miniconda3/envs/test/lib/python3.11/site-packages/docarray/array/doc_list/io.py:542, in IOMixinArray.to_dataframe(self)
    535 if self.doc_type == AnyDoc:
    536     raise TypeError(
    537         'DocList must be homogeneous to be converted to a DataFrame.'
    538         'There is no document schema defined. '
    539         'Please specify the DocList\'s Document type using `DocList[MyDoc]`.'
    540     )
--> 542 fields = self.doc_type._get_access_paths()
    543 df = pd.DataFrame(columns=fields)
    545 for doc in self:

File ~/miniconda3/envs/test/lib/python3.11/site-packages/docarray/base_doc/mixins/io.py:397, in IOMixin._get_access_paths(cls)
    395 for field in cls.__fields__.keys():
    396     field_type = cls._get_field_type(field)
--> 397     if not is_union_type(field_type) and issubclass(field_type, BaseDoc):
    398         sub_paths = field_type._get_access_paths()
    399         for path in sub_paths:

File <frozen abc>:123, in __subclasscheck__(cls, subclass)

TypeError: issubclass() arg 1 must be a class```

Activity

  1. JoanFM commented on May 28, 2023

    @JoanFM
    Member

    What is the docarray version you are using?

  2. moved this to Todo/Bug in DocArray backlogon May 28, 2023
  3. lazyhope commented on May 28, 2023

    @lazyhope
    Author

    0.32.1

  4. JoanFM commented on May 28, 2023

    @JoanFM
    Member

    Okey @lazyhope ,

    Thanks for reporting. There is an instance of a call to issubclass that was left untouched.

    We will fix this ASAP.

  5. lazyhope commented on May 28, 2023

    @lazyhope
    Author

    Thanks a lot!

  6. linked a pull request that will close this issuefix: solve issues caused by issubclass #1594on May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions