Skip to content

Commit

Permalink
Python <= 3.7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmullen committed Aug 29, 2023
1 parent d1a4a36 commit b981cdf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ninja/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def _find_collection_response(op: Operation) -> Tuple[int, Any]:
class Cursor:
offset: int = 0
reverse: bool = False
position: str | None = None
position: Optional[str] = None


def _clamp(val: int, min_: int, max_: int) -> int:
Expand Down Expand Up @@ -272,14 +272,14 @@ def _replace_query_param(url: str, key: str, val: str):

class CursorPagination(PaginationBase):
class Input(Schema):
limit: int | None = Field(None, description=_("Number of results to return per page."))
cursor: str | None = Field(
limit: Optional[int] = Field(None, description=_("Number of results to return per page."))
cursor: Optional[str] = Field(
None, description=_("The pagination cursor value."), validate_default=True
)

@field_validator("cursor")
@classmethod
def decode_cursor(cls, encoded_cursor: str | None) -> Cursor:
def decode_cursor(cls, encoded_cursor: Optional[str]) -> Cursor:
if encoded_cursor is None:
return Cursor()

Expand All @@ -300,10 +300,10 @@ def decode_cursor(cls, encoded_cursor: str | None) -> Cursor:
return Cursor(offset=offset, reverse=reverse, position=position)

class Output(Schema):
results: list[Any] = Field(description=_("The page of objects."))
results: List[Any] = Field(description=_("The page of objects."))
count: int = Field(description=_("The total number of results across all pages."))
next: str | None = Field(description=_("URL of next page of results if there is one."))
previous: str | None = Field(
next: Optional[str] = Field(description=_("URL of next page of results if there is one."))
previous: Optional[str] = Field(
description=_("URL of previous page of results if there is one.")
)

Expand Down

0 comments on commit b981cdf

Please sign in to comment.