4848 Body ,
4949 Omit ,
5050 Query ,
51- ModelT ,
5251 Headers ,
5352 Timeout ,
5453 NotGiven ,
6160 HttpxSendArgs ,
6261 AsyncTransport ,
6362 RequestOptions ,
64- UnknownResponse ,
6563 ModelBuilderProtocol ,
6664 BinaryResponseContent ,
6765)
@@ -142,7 +140,7 @@ def __init__(
142140 self .params = params
143141
144142
145- class BasePage (GenericModel , Generic [ModelT ]):
143+ class BasePage (GenericModel , Generic [_T ]):
146144 """
147145 Defines the core interface for pagination.
148146
@@ -155,7 +153,7 @@ class BasePage(GenericModel, Generic[ModelT]):
155153 """
156154
157155 _options : FinalRequestOptions = PrivateAttr ()
158- _model : Type [ModelT ] = PrivateAttr ()
156+ _model : Type [_T ] = PrivateAttr ()
159157
160158 def has_next_page (self ) -> bool :
161159 items = self ._get_page_items ()
@@ -166,7 +164,7 @@ def has_next_page(self) -> bool:
166164 def next_page_info (self ) -> Optional [PageInfo ]:
167165 ...
168166
169- def _get_page_items (self ) -> Iterable [ModelT ]: # type: ignore[empty-body]
167+ def _get_page_items (self ) -> Iterable [_T ]: # type: ignore[empty-body]
170168 ...
171169
172170 def _params_from_url (self , url : URL ) -> httpx .QueryParams :
@@ -191,13 +189,13 @@ def _info_to_options(self, info: PageInfo) -> FinalRequestOptions:
191189 raise ValueError ("Unexpected PageInfo state" )
192190
193191
194- class BaseSyncPage (BasePage [ModelT ], Generic [ModelT ]):
192+ class BaseSyncPage (BasePage [_T ], Generic [_T ]):
195193 _client : SyncAPIClient = pydantic .PrivateAttr ()
196194
197195 def _set_private_attributes (
198196 self ,
199197 client : SyncAPIClient ,
200- model : Type [ModelT ],
198+ model : Type [_T ],
201199 options : FinalRequestOptions ,
202200 ) -> None :
203201 self ._model = model
@@ -212,7 +210,7 @@ def _set_private_attributes(
212210 # methods should continue to work as expected as there is an alternative method
213211 # to cast a model to a dictionary, model.dict(), which is used internally
214212 # by pydantic.
215- def __iter__ (self ) -> Iterator [ModelT ]: # type: ignore
213+ def __iter__ (self ) -> Iterator [_T ]: # type: ignore
216214 for page in self .iter_pages ():
217215 for item in page ._get_page_items ():
218216 yield item
@@ -237,13 +235,13 @@ def get_next_page(self: SyncPageT) -> SyncPageT:
237235 return self ._client ._request_api_list (self ._model , page = self .__class__ , options = options )
238236
239237
240- class AsyncPaginator (Generic [ModelT , AsyncPageT ]):
238+ class AsyncPaginator (Generic [_T , AsyncPageT ]):
241239 def __init__ (
242240 self ,
243241 client : AsyncAPIClient ,
244242 options : FinalRequestOptions ,
245243 page_cls : Type [AsyncPageT ],
246- model : Type [ModelT ],
244+ model : Type [_T ],
247245 ) -> None :
248246 self ._model = model
249247 self ._client = client
@@ -266,7 +264,7 @@ def _parser(resp: AsyncPageT) -> AsyncPageT:
266264
267265 return await self ._client .request (self ._page_cls , self ._options )
268266
269- async def __aiter__ (self ) -> AsyncIterator [ModelT ]:
267+ async def __aiter__ (self ) -> AsyncIterator [_T ]:
270268 # https://github.com/microsoft/pyright/issues/3464
271269 page = cast (
272270 AsyncPageT ,
@@ -276,20 +274,20 @@ async def __aiter__(self) -> AsyncIterator[ModelT]:
276274 yield item
277275
278276
279- class BaseAsyncPage (BasePage [ModelT ], Generic [ModelT ]):
277+ class BaseAsyncPage (BasePage [_T ], Generic [_T ]):
280278 _client : AsyncAPIClient = pydantic .PrivateAttr ()
281279
282280 def _set_private_attributes (
283281 self ,
284- model : Type [ModelT ],
282+ model : Type [_T ],
285283 client : AsyncAPIClient ,
286284 options : FinalRequestOptions ,
287285 ) -> None :
288286 self ._model = model
289287 self ._client = client
290288 self ._options = options
291289
292- async def __aiter__ (self ) -> AsyncIterator [ModelT ]:
290+ async def __aiter__ (self ) -> AsyncIterator [_T ]:
293291 async for page in self .iter_pages ():
294292 for item in page ._get_page_items ():
295293 yield item
@@ -528,7 +526,7 @@ def _process_response_data(
528526 if data is None :
529527 return cast (ResponseT , None )
530528
531- if cast_to is UnknownResponse :
529+ if cast_to is object :
532530 return cast (ResponseT , data )
533531
534532 try :
@@ -970,7 +968,7 @@ def _retry_request(
970968
971969 def _request_api_list (
972970 self ,
973- model : Type [ModelT ],
971+ model : Type [object ],
974972 page : Type [SyncPageT ],
975973 options : FinalRequestOptions ,
976974 ) -> SyncPageT :
@@ -1132,7 +1130,7 @@ def get_api_list(
11321130 self ,
11331131 path : str ,
11341132 * ,
1135- model : Type [ModelT ],
1133+ model : Type [object ],
11361134 page : Type [SyncPageT ],
11371135 body : Body | None = None ,
11381136 options : RequestOptions = {},
@@ -1434,10 +1432,10 @@ async def _retry_request(
14341432
14351433 def _request_api_list (
14361434 self ,
1437- model : Type [ModelT ],
1435+ model : Type [_T ],
14381436 page : Type [AsyncPageT ],
14391437 options : FinalRequestOptions ,
1440- ) -> AsyncPaginator [ModelT , AsyncPageT ]:
1438+ ) -> AsyncPaginator [_T , AsyncPageT ]:
14411439 return AsyncPaginator (client = self , options = options , page_cls = page , model = model )
14421440
14431441 @overload
@@ -1584,13 +1582,12 @@ def get_api_list(
15841582 self ,
15851583 path : str ,
15861584 * ,
1587- # TODO: support paginating `str`
1588- model : Type [ModelT ],
1585+ model : Type [_T ],
15891586 page : Type [AsyncPageT ],
15901587 body : Body | None = None ,
15911588 options : RequestOptions = {},
15921589 method : str = "get" ,
1593- ) -> AsyncPaginator [ModelT , AsyncPageT ]:
1590+ ) -> AsyncPaginator [_T , AsyncPageT ]:
15941591 opts = FinalRequestOptions .construct (method = method , url = path , json_data = body , ** options )
15951592 return self ._request_api_list (model , page , opts )
15961593
0 commit comments