Home / File/ pagination.py — anthropic-sdk-python Source File

pagination.py — anthropic-sdk-python Source File

Architecture documentation for pagination.py, a python file in the anthropic-sdk-python codebase. 7 imports, 0 dependents.

File python AnthropicClient AsyncAPI 7 imports 6 classes

Entity Profile

Dependency Diagram

graph LR
  b906442a_92b7_2131_d6a5_3712533b82f2["pagination.py"]
  31e60ad8_cac8_652d_176d_4f7cf7dda1ad["_base_client.py"]
  b906442a_92b7_2131_d6a5_3712533b82f2 --> 31e60ad8_cac8_652d_176d_4f7cf7dda1ad
  3543329f_b8e7_6257_bf27_c9c0879f8b2b["BasePage"]
  b906442a_92b7_2131_d6a5_3712533b82f2 --> 3543329f_b8e7_6257_bf27_c9c0879f8b2b
  7c07fcc0_f706_66c2_3896_279eabb44e16["PageInfo"]
  b906442a_92b7_2131_d6a5_3712533b82f2 --> 7c07fcc0_f706_66c2_3896_279eabb44e16
  c0f008e5_ad6e_1b9d_0800_826eae176f95["BaseSyncPage"]
  b906442a_92b7_2131_d6a5_3712533b82f2 --> c0f008e5_ad6e_1b9d_0800_826eae176f95
  974ecd7e_1e02_c86a_c8bf_b2cfbc7e936e["BaseAsyncPage"]
  b906442a_92b7_2131_d6a5_3712533b82f2 --> 974ecd7e_1e02_c86a_c8bf_b2cfbc7e936e
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  b906442a_92b7_2131_d6a5_3712533b82f2 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"]
  b906442a_92b7_2131_d6a5_3712533b82f2 --> 37c05070_ca59_d596_7250_de9d1939227f
  style b906442a_92b7_2131_d6a5_3712533b82f2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Generic, TypeVar, Optional
from typing_extensions import override

from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage

__all__ = ["SyncPage", "AsyncPage", "SyncTokenPage", "AsyncTokenPage", "SyncPageCursor", "AsyncPageCursor"]

_T = TypeVar("_T")


class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
    data: List[_T]
    has_more: Optional[bool] = None
    first_id: Optional[str] = None
    last_id: Optional[str] = None

    @override
    def _get_page_items(self) -> List[_T]:
        data = self.data
        if not data:
            return []
        return data

    @override
    def has_next_page(self) -> bool:
        has_more = self.has_more
        if has_more is not None and has_more is False:
            return False

        return super().has_next_page()

    @override
    def next_page_info(self) -> Optional[PageInfo]:
        if self._options.params.get("before_id"):
            first_id = self.first_id
            if not first_id:
                return None

            return PageInfo(params={"before_id": first_id})

        last_id = self.last_id
        if not last_id:
            return None

        return PageInfo(params={"after_id": last_id})


class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
    data: List[_T]
    has_more: Optional[bool] = None
    first_id: Optional[str] = None
    last_id: Optional[str] = None

    @override
    def _get_page_items(self) -> List[_T]:
        data = self.data
        if not data:
            return []
// ... (141 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does pagination.py do?
pagination.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, AsyncAPI subdomain.
What does pagination.py depend on?
pagination.py imports 7 module(s): BaseAsyncPage, BasePage, BaseSyncPage, PageInfo, _base_client.py, typing, typing_extensions.
Where is pagination.py in the architecture?
pagination.py is located at src/anthropic/pagination.py (domain: AnthropicClient, subdomain: AsyncAPI, directory: src/anthropic).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free