Skip to content

Commit

Permalink
refactor: Mark pagination classes with @override decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Aug 9, 2024
1 parent e0efe9c commit 82a4f9f
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions singer_sdk/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

from __future__ import annotations

import sys
import typing as t
from abc import ABCMeta, abstractmethod
from urllib.parse import ParseResult, urlparse

from singer_sdk.helpers.jsonpath import extract_jsonpath

if sys.version_info < (3, 12):
from typing_extensions import override
else:
from typing import override # noqa: ICN003

if t.TYPE_CHECKING:
from requests import Response

Expand Down Expand Up @@ -155,15 +161,12 @@ def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
"""
super().__init__(None, *args, **kwargs)

def get_next(self, response: Response) -> None: # noqa: ARG002, PLR6301
"""Get the next pagination token or index from the API response.
@override
def get_next(self, response: Response) -> None:
"""Always return None to indicate pagination is complete after the first page.
Args:
response: API response object.
Returns:
The next page token or index. Return `None` from this method to indicate
the end of pagination.
"""
return

Expand Down Expand Up @@ -228,6 +231,7 @@ def get_next_url(self, response: Response) -> str | None:
"""
...

@override
def get_next(self, response: Response) -> ParseResult | None:
"""Get the next pagination token or index from the API response.
Expand All @@ -249,7 +253,8 @@ class HeaderLinkPaginator(BaseHATEOASPaginator):
- https://datatracker.ietf.org/doc/html/rfc8288#section-3
"""

def get_next_url(self, response: Response) -> str | None: # noqa: PLR6301
@override
def get_next_url(self, response: Response) -> str | None:
"""Override this method to extract a HATEOAS link from the response.
Args:
Expand Down Expand Up @@ -281,6 +286,7 @@ def __init__(
super().__init__(None, *args, **kwargs)
self._jsonpath = jsonpath

@override
def get_next(self, response: Response) -> str | None:
"""Get the next page token.
Expand Down Expand Up @@ -313,6 +319,7 @@ def __init__(
super().__init__(None, *args, **kwargs)
self._key = key

@override
def get_next(self, response: Response) -> str | None:
"""Get the next page token.
Expand All @@ -328,7 +335,8 @@ def get_next(self, response: Response) -> str | None:
class BasePageNumberPaginator(BaseAPIPaginator[int], metaclass=ABCMeta):
"""Paginator class for APIs that use page number."""

def get_next(self, response: Response) -> int | None: # noqa: ARG002
@override
def get_next(self, response: Response) -> int | None:
"""Get the next page number.
Args:
Expand Down Expand Up @@ -361,7 +369,8 @@ def __init__(
super().__init__(start_value, *args, **kwargs)
self._page_size = page_size

def get_next(self, response: Response) -> int | None: # noqa: ARG002
@override
def get_next(self, response: Response) -> int | None:
"""Get the next page offset.
Args:
Expand Down Expand Up @@ -411,6 +420,7 @@ def __init__(
super().__init__(None, *args, **kwargs)
self.stream = stream

@override
def get_next(self, response: Response) -> TPageToken | None:
"""Get next page value by calling the stream method.
Expand Down

0 comments on commit 82a4f9f

Please sign in to comment.