refactor: simplify da type checking#224
Conversation
Codecov Report
@@ Coverage Diff @@
## main #224 +/- ##
==========================================
+ Coverage 81.18% 85.28% +4.09%
==========================================
Files 123 123
Lines 5677 5667 -10
==========================================
+ Hits 4609 4833 +224
+ Misses 1068 834 -234
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
@alaeddine-13 can you review it |
alaeddine-13
left a comment
There was a problem hiding this comment.
Maybe it's clearer to just check for Iterable
| ) | ||
| and self._ref_doc is not None | ||
| ): | ||
| if isinstance(docs, (Iterable, Iterator)) and self._ref_doc is not None: |
There was a problem hiding this comment.
Iterator is also a subclass of Iterable so we can just keep Iterable here
| if isinstance(docs, (Iterable, Iterator)) and self._ref_doc is not None: | |
| if isinstance(docs, Iterable) and self._ref_doc is not None: |
| ) | ||
| and self._ref_doc is not None | ||
| ): | ||
| if isinstance(docs, (Iterable, Iterator)) and self._ref_doc is not None: |
There was a problem hiding this comment.
| if isinstance(docs, (Iterable, Iterator)) and self._ref_doc is not None: | |
| if isinstance(docs, Iterable) and self._ref_doc is not None: |
| if isinstance( | ||
| _docs, (DocumentArray, Sequence, Generator, Iterator, itertools.chain) | ||
| ): | ||
| if isinstance(_docs, (Iterable, Iterator)): |
There was a problem hiding this comment.
| if isinstance(_docs, (Iterable, Iterator)): | |
| if isinstance(_docs, Iterable): |
| elif isinstance( | ||
| _docs, | ||
| (DocumentArray, Sequence, Generator, Iterator, itertools.chain), | ||
| (Iterable, Iterator), |
| if isinstance( | ||
| docs, (DocumentArray, Sequence, Generator, Iterator, itertools.chain) | ||
| ): | ||
| if isinstance(docs, (Iterable, Iterator)): |
There was a problem hiding this comment.
| if isinstance(docs, (Iterable, Iterator)): | |
| if isinstance(docs, Iterable): |
| elif isinstance( | ||
| _docs, (DocumentArray, Sequence, Generator, Iterator, itertools.chain) | ||
| ): | ||
| elif isinstance(_docs, (Iterable, Iterator)): |
There was a problem hiding this comment.
| elif isinstance(_docs, (Iterable, Iterator)): | |
| elif isinstance(_docs, Iterable): |
| elif isinstance( | ||
| _docs, (DocumentArray, Sequence, Generator, Iterator, itertools.chain) | ||
| ): | ||
| elif isinstance(_docs, (Iterable, Iterator)): |
There was a problem hiding this comment.
| elif isinstance(_docs, (Iterable, Iterator)): | |
| elif isinstance(_docs, Iterable): |
DocumentArrayisMutableSequence->Sequence->Iterable.iter(da)isGenerator->Iterator->Iterable.chain(da1, da2)is bothIterableandIterator.Maybe we only need to check 1 type