Skip to content

fix: update pagination scheme #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions src/codex/pagination.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Any, List, Type, Generic, Mapping, TypeVar, Optional, cast
from typing import List, Generic, TypeVar, Optional
from typing_extensions import override

from httpx import Response

from ._utils import is_mapping
from ._models import BaseModel
from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage

__all__ = ["SyncMyOffsetPage", "AsyncMyOffsetPage"]

_BaseModelT = TypeVar("_BaseModelT", bound=BaseModel)

_T = TypeVar("_T")


Expand All @@ -37,15 +31,6 @@ def next_page_info(self) -> Optional[PageInfo]:

return PageInfo(params={"offset": current_count})

@classmethod
def build(cls: Type[_BaseModelT], *, response: Response, data: object) -> _BaseModelT: # noqa: ARG003
return cls.construct(
None,
**{
**(cast(Mapping[str, Any], data) if is_mapping(data) else {"items": data}),
},
)


class AsyncMyOffsetPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
items: List[_T]
Expand All @@ -67,12 +52,3 @@ def next_page_info(self) -> Optional[PageInfo]:
current_count = offset + length

return PageInfo(params={"offset": current_count})

@classmethod
def build(cls: Type[_BaseModelT], *, response: Response, data: object) -> _BaseModelT: # noqa: ARG003
return cls.construct(
None,
**{
**(cast(Mapping[str, Any], data) if is_mapping(data) else {"items": data}),
},
)