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: patch-diff.githubusercontent.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:b9956972-ac02-09ef-61e4-c7fc26e9e0e2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE62:16196:47D89:62500:6982FFC1 |
| html-safe-nonce | 7168e4e388ca862042314bc77072edae80db612c035ccf1e62797ea9b8f7fc71 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTYyOjE2MTk2OjQ3RDg5OjYyNTAwOjY5ODJGRkMxIiwidmlzaXRvcl9pZCI6IjU5NDk5ODY0ODk2NjkzODU2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 35df988d4d950df1c3ef0319d57efeffb2620c3a3dc7cae950cae9acac710ccd |
| 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 | c6741528aa4d4ba81c57bbff8f8cc0de0e9115cb2993431dc9dac8d489f7b4ee |
| 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 | df2a3cea9cc9adaf422cd462f5351935c407af4d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width