@@ -316,7 +316,7 @@ def index(
316
316
)
317
317
raise ValueError (msg )
318
318
319
- if (cleanup == "incremental" or cleanup == "scoped_full" ) and source_id_key is None :
319
+ if (cleanup in { "incremental" , "scoped_full" } ) and source_id_key is None :
320
320
msg = (
321
321
"Source id key is required when cleanup mode is incremental or scoped_full."
322
322
)
@@ -379,7 +379,7 @@ def index(
379
379
source_id_assigner (doc ) for doc in hashed_docs
380
380
]
381
381
382
- if cleanup == "incremental" or cleanup == "scoped_full" :
382
+ if cleanup in { "incremental" , "scoped_full" } :
383
383
# source ids are required.
384
384
for source_id , hashed_doc in zip (source_ids , hashed_docs ):
385
385
if source_id is None :
@@ -622,7 +622,7 @@ async def aindex(
622
622
)
623
623
raise ValueError (msg )
624
624
625
- if (cleanup == "incremental" or cleanup == "scoped_full" ) and source_id_key is None :
625
+ if (cleanup in { "incremental" , "scoped_full" } ) and source_id_key is None :
626
626
msg = (
627
627
"Source id key is required when cleanup mode is incremental or scoped_full."
628
628
)
@@ -667,11 +667,10 @@ async def aindex(
667
667
# In such a case, we use the load method and convert it to an async
668
668
# iterator.
669
669
async_doc_iterator = _to_async_iterator (docs_source .load ())
670
+ elif hasattr (docs_source , "__aiter__" ):
671
+ async_doc_iterator = docs_source # type: ignore[assignment]
670
672
else :
671
- if hasattr (docs_source , "__aiter__" ):
672
- async_doc_iterator = docs_source # type: ignore[assignment]
673
- else :
674
- async_doc_iterator = _to_async_iterator (docs_source )
673
+ async_doc_iterator = _to_async_iterator (docs_source )
675
674
676
675
source_id_assigner = _get_source_id_assigner (source_id_key )
677
676
@@ -694,7 +693,7 @@ async def aindex(
694
693
source_id_assigner (doc ) for doc in hashed_docs
695
694
]
696
695
697
- if cleanup == "incremental" or cleanup == "scoped_full" :
696
+ if cleanup in { "incremental" , "scoped_full" } :
698
697
# If the cleanup mode is incremental, source ids are required.
699
698
for source_id , hashed_doc in zip (source_ids , hashed_docs ):
700
699
if source_id is None :
0 commit comments