Title: DocList raises exception for type object. · Issue #1828 · docarray/docarray · GitHub
Open Graph Title: DocList raises exception for type object. · Issue #1828 · docarray/docarray
X Title: DocList raises exception for type object. · Issue #1828 · docarray/docarray
Description: 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 i...
Open Graph Description: 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, ob...
X Description: 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, ob...
Opengraph URL: https://github.com/docarray/docarray/issues/1828
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"DocList raises exception for type object.","articleBody":"### Initial Checks\r\n\r\n- [X] I have read and followed [the docs](https://docs.docarray.org/) and still think this is a bug\r\n\r\n### Description\r\n\r\nThis [commit](https://github.com/docarray/docarray/commit/2f3b85e333446cfa9b8c4877c4ccf9ae49cae660) introduced a check to verify that DocList is not used with an object: \r\n```\r\n if (\r\n isinstance(item, object)\r\n and not is_typevar(item)\r\n and not isinstance(item, str)\r\n and item is not Any\r\n ):\r\n raise TypeError('Expecting a type, got object instead')\r\n ```\r\n\r\nThis is quite a broad condition (it breaks things like `DocList[TorchTensor]`, or nested `DocList[DocList[...]]` for me for instance) as:\r\n- Almost everything will be an object so the first line if almost a catch-all. \r\n- `is_typevar` only checks for TypeVar objects.\r\n\r\nShould this not check as well for something `not isinstance(item, type)` instead of `not is_typevar` to allow for classes ?\r\nThis way only non class objects (like instances of class object that are not classes themselves) will raise the `TypeError`. \r\n\r\n### Example Code\r\n\r\n```Python\r\nfrom docarray import DocList\r\nfrom docarray.typing import TorchTensor\r\ntest = DocList[TorchTensor]\r\n```\r\n\r\n\r\n### Python, DocArray \u0026 OS Version\r\n\r\n```Text\r\n0.39.1\r\n```\r\n\r\n\r\n### Affected Components\r\n\r\n- [ ] [Vector Database / Index](https://docs.docarray.org/user_guide/storing/docindex/)\r\n- [X] [Representing](https://docs.docarray.org/user_guide/representing/first_step)\r\n- [ ] [Sending](https://docs.docarray.org/user_guide/sending/first_step/)\r\n- [ ] [storing](https://docs.docarray.org/user_guide/storing/first_step/)\r\n- [X] [multi modal data type](https://docs.docarray.org/data_types/first_steps/)","author":{"url":"https://github.com/corentinmarek","@type":"Person","name":"corentinmarek"},"datePublished":"2023-10-30T19:17:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/1828/docarray/issues/1828"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7e76860a-6898-5dfd-75af-4bdc45a082da |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D79A:2ADE67:1AC313F:249C7A6:6964BFCE |
| html-safe-nonce | 78326a96325c912ce53307e5db90cdcf6fa35bd839ab61ea0f5a86229dad38e2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzlBOjJBREU2NzoxQUMzMTNGOjI0OUM3QTY6Njk2NEJGQ0UiLCJ2aXNpdG9yX2lkIjoiMjE3MDkxNTQxOTM3NzE1NjA0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d5d75db669050c74c8bf6fd80160ae07f7d100883b155daa497cb661d09e9663 |
| hovercard-subject-tag | issue:1969052553 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/docarray/docarray/1828/issue_layout |
| twitter:image | https://opengraph.githubassets.com/55abe305b4c42c3a8f1c7e54e61e36bad7095de38d79f60d3f203b0a828998bd/docarray/docarray/issues/1828 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/55abe305b4c42c3a8f1c7e54e61e36bad7095de38d79f60d3f203b0a828998bd/docarray/docarray/issues/1828 |
| og:image:alt | 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, ob... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | corentinmarek |
| hostname | github.com |
| expected-hostname | github.com |
| None | 21df671ce2c9f1a16940ccbd3af6cb4f3f12a856929ca7eb1b4aea8e384ea442 |
| turbo-cache-control | no-preview |
| go-import | github.com/docarray/docarray git https://github.com/docarray/docarray.git |
| octolytics-dimension-user_id | 117445116 |
| octolytics-dimension-user_login | docarray |
| octolytics-dimension-repository_id | 438303578 |
| octolytics-dimension-repository_nwo | docarray/docarray |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 438303578 |
| octolytics-dimension-repository_network_root_nwo | docarray/docarray |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5707c685ac172d50a0bdd7533dde4f8aabcf8eef |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width