11from datetime import datetime , timezone , UTC
2- from typing import Sequence
2+ from collections .abc import Sequence
3+ from typing import Any
34import math
45
56from app import constants
@@ -16,23 +17,25 @@ def to_timestamp(date: datetime | None) -> int | None:
1617
1718
1819# Helper function for pagination
19- def pagination (page , size = constants .DEFAULT_PAGINATION_SIZE ):
20+ def pagination (page : int , size : int = constants .DEFAULT_PAGINATION_SIZE ):
2021 """limit, offset = pagination(:page, :page_size)"""
2122 offset = (size * page ) - size
2223
2324 return size , offset
2425
2526
2627# Helper function to make pagination dict for api
27- def pagination_dict (total , page , limit ) :
28+ def pagination_dict (total : int , page : int , limit : int ) -> dict [ str , int ] :
2829 return {
2930 "pages" : math .ceil (total / limit ),
3031 "total" : total ,
3132 "page" : page ,
3233 }
3334
3435
35- def paginated_response (items : Sequence , total : int , page : int , limit : int ) -> dict :
36+ def paginated_response (
37+ items : Sequence [Any ], total : int , page : int , limit : int
38+ ) -> dict [str , Any ]:
3639 return {
3740 "pagination" : pagination_dict (total , page , limit ),
3841 "list" : items ,
0 commit comments