Skip to content

Commit

Permalink
Fix TypeError: 'type' object is not subscriptable if using python ver…
Browse files Browse the repository at this point in the history
…sions 3.7 or 3.8
  • Loading branch information
slymit committed Jun 12, 2024
1 parent accd7bc commit 7b60588
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sa_filters/pagination.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import math
from collections import namedtuple
import sys
from typing import Optional, Union

from sqlalchemy.sql import Select
Expand All @@ -9,6 +10,12 @@
from .exceptions import InvalidPage


if sys.version_info < (3, 9): # pragma: nocover
from typing import Tuple as TupleType
else: # pragma: nocover
TupleType = tuple


Pagination = namedtuple(
'Pagination', ['page_number', 'page_size', 'num_pages', 'total_results']
)
Expand All @@ -19,7 +26,7 @@ def apply_pagination(
page_number: Optional[int] = None,
page_size: Optional[int] = None,
total_results: int = 0
) -> tuple[Union[Select, Query], Pagination]:
) -> TupleType[Union[Select, Query], Pagination]:
"""Apply pagination to a SQLAlchemy query or Select object.
:param stmt:
Expand Down

0 comments on commit 7b60588

Please sign in to comment.