GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DocList raises exception for type object. · Issue #1828 · docarray/docarray

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.

DocList raises exception for type object. #1828

Copy link
Copy link
Open
#1829
Open
DocList raises exception for type object.#1828
#1829
Copy link

Description

@corentinmarek
corentinmarek
opened on Oct 30, 2023
Issue body actions

Initial Checks

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

Description

This commit introduced a check to verify that DocList is not used with an object:

        if (
            isinstance(item, object)
            and not is_typevar(item)
            and not isinstance(item, str)
            and item is not Any
        ):
               raise TypeError('Expecting a type, got object instead')

This is quite a broad condition (it breaks things like DocList[TorchTensor], or nested DocList[DocList[...]] for me for instance) as:

  • Almost everything will be an object so the first line if almost a catch-all.
  • is_typevar only checks for TypeVar objects.

Should this not check as well for something not isinstance(item, type) instead of not is_typevar to allow for classes ?
This way only non class objects (like instances of class object that are not classes themselves) will raise the TypeError.

Example Code

from docarray import DocList
from docarray.typing import TorchTensor
test = DocList[TorchTensor]

Python, DocArray & OS Version

0.39.1

Affected Components

  • Vector Database / Index
  • Representing
  • Sending
  • storing
  • multi modal data type

Activity

  1. JoanFM commented on Oct 30, 2023

    @JoanFM
    JoanFM
    on Oct 30, 2023
    Member
    More actions

    Hello @corentinmarek,

    It would be very helpful if you could provide a draft PR with your idea for a better implementatiom of this.

  2. corentinmarek commented on Oct 31, 2023

    @corentinmarek
    corentinmarek
    on Oct 31, 2023
    Author
    More actions

    👍: #1829. Waiting for checks.

  3. JoanFM
    linked a pull request that will close this issuefeat(array): allow for type object with DocList #1829on Oct 31, 2023
  4. JoanFM commented on Oct 31, 2023

    @JoanFM
    JoanFM
    on Oct 31, 2023
    Member
    More actions

    However, I am not sure DocList[TorchTensor] and DocList[DocList[...]] will work as now, because they are not BaseDoc

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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.