11__all__ = ["paginate" ]
22
3- from typing import Any , Dict , List , Optional , Sequence
3+ from typing import Any , Dict , List , Optional
44
55from motor .core import AgnosticCollection
66
@@ -14,7 +14,7 @@ async def paginate(
1414 collection : AgnosticCollection ,
1515 query_filter : Optional [Dict [Any , Any ]] = None ,
1616 params : Optional [AbstractParams ] = None ,
17- sort : Optional [Sequence [ Any ] ] = None ,
17+ sort : Optional [Any ] = None ,
1818 * ,
1919 transformer : Optional [AsyncItemsTransformer ] = None ,
2020 additional_data : Optional [AdditionalData ] = None ,
@@ -26,7 +26,7 @@ async def paginate(
2626 total = await collection .count_documents (query_filter )
2727 cursor = collection .find (query_filter , skip = raw_params .offset , limit = raw_params .limit , ** kwargs )
2828 if sort is not None :
29- cursor = cursor .sort (* sort )
29+ cursor = cursor .sort (* sort ) if isinstance ( sort , tuple ) else cursor . sort ( sort )
3030
3131 items = await cursor .to_list (length = raw_params .limit ) # type: ignore[arg-type]
3232 t_items = await apply_items_transformer (items , transformer , async_ = True )
0 commit comments