fix: raise exception when type of DocList is object#1794
fix: raise exception when type of DocList is object#1794JoanFM merged 2 commits intodocarray:mainfrom
Conversation
docarray/array/doc_list/doc_list.py
Outdated
| else: | ||
| return super().__class_getitem__(item) | ||
|
|
||
| if isinstance(item, object) and not isinstance(item, TypeVar): |
There was a problem hiding this comment.
added a check isinstance(item, TypeVar) since item of TypeVar was also being passed when __class_getitem__ was called
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1794 +/- ##
==========================================
+ Coverage 84.24% 84.81% +0.56%
==========================================
Files 135 135
Lines 8899 8901 +2
==========================================
+ Hits 7497 7549 +52
+ Misses 1402 1352 -50
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
|
Hey @punndcoder28, please make sure to add relevant tests for this |
08b7e7b to
8621817
Compare
| return AnyDocArray.__class_getitem__.__func__(cls, item) # type: ignore | ||
| else: | ||
| return super().__class_getitem__(item) | ||
| if ( |
There was a problem hiding this comment.
Since each condition has a terminating condition from the function wouldn't multiple if's be similar to elif? If there was a scenario like below an elif would definitely make it much better. In the above case, we check the instance of item and based on the condition we return a type or raise an exception. But if the code base follows if ... elif ... else blocks I would love to keep it uniform so that it is easy to maintain
computation
if condn1:
computation = value1
elif condn2:
computation = value2
else:
computation = value3
return computation
|
Will fix the failing tests related to new changes |
|
@JoanFM Can we pass string literal as types for a class? Like so This is being done here docarray/tests/units/array/test_array.py Line 383 in 8f32866 |
2144b3c to
1a727be
Compare
u can in the type hints |
Signed-off-by: punndcoder28 <puneethk.2899@gmail.com>
1a727be to
8266238
Compare
DocListwithout causing code to raise expection as mentioned in Bug with DocList[] #1782Test Plan - Running the below code raises exception
Exception raise