File tree Expand file tree Collapse file tree 4 files changed +32
-29
lines changed Expand file tree Collapse file tree 4 files changed +32
-29
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,12 @@ authors = [
88{ name = " OpenAI" , email = " support@openai.com" },
99]
1010dependencies = [
11- " httpx>=0.23.0, <1" ,
12- " pydantic>=1.9.0, <3" ,
13- " typing-extensions>=4.5, <5" ,
14- " anyio>=3.5.0, <4" ,
15- " distro>=1.7.0, <2" ,
16- " tqdm > 4"
11+ " httpx>=0.23.0, <1" ,
12+ " pydantic>=1.9.0, <3" ,
13+ " typing-extensions>=4.5, <5" ,
14+ " anyio>=3.5.0, <4" ,
15+ " distro>=1.7.0, <2" ,
16+ " tqdm > 4"
1717]
1818requires-python = " >= 3.7.1"
1919
@@ -30,17 +30,17 @@ openai = "openai.cli:main"
3030[tool .rye ]
3131managed = true
3232dev-dependencies = [
33- " pyright==1.1.326 " ,
34- " mypy==1.4.1" ,
35- " black==23.3.0" ,
36- " respx==0.19.2" ,
37- " pytest==7.1.1" ,
38- " pytest-asyncio==0.21.1" ,
39- " ruff==0.0.282" ,
40- " isort==5.10.1" ,
41- " time-machine==2.9.0" ,
42- " nox==2023.4.22" ,
43- " types-tqdm > 4"
33+ " pyright==1.1.332 " ,
34+ " mypy==1.4.1" ,
35+ " black==23.3.0" ,
36+ " respx==0.19.2" ,
37+ " pytest==7.1.1" ,
38+ " pytest-asyncio==0.21.1" ,
39+ " ruff==0.0.282" ,
40+ " isort==5.10.1" ,
41+ " time-machine==2.9.0" ,
42+ " nox==2023.4.22" ,
43+ " types-tqdm > 4"
4444]
4545
4646[tool .rye .scripts ]
Original file line number Diff line number Diff line change @@ -315,8 +315,11 @@ async def get_next_page(self: AsyncPageT) -> AsyncPageT:
315315 return await self ._client ._request_api_list (self ._model , page = self .__class__ , options = options )
316316
317317
318- class BaseClient :
319- _client : httpx .Client | httpx .AsyncClient
318+ _HttpxClientT = TypeVar ("_HttpxClientT" , bound = Union [httpx .Client , httpx .AsyncClient ])
319+
320+
321+ class BaseClient (Generic [_HttpxClientT ]):
322+ _client : _HttpxClientT
320323 _version : str
321324 _base_url : URL
322325 max_retries : int
@@ -730,7 +733,7 @@ def _idempotency_key(self) -> str:
730733 return f"stainless-python-retry-{ uuid .uuid4 ()} "
731734
732735
733- class SyncAPIClient (BaseClient ):
736+ class SyncAPIClient (BaseClient [ httpx . Client ] ):
734737 _client : httpx .Client
735738 _has_custom_http_client : bool
736739 _default_stream_cls : type [Stream [Any ]] | None = None
@@ -1136,7 +1139,7 @@ def get_api_list(
11361139 return self ._request_api_list (model , page , opts )
11371140
11381141
1139- class AsyncAPIClient (BaseClient ):
1142+ class AsyncAPIClient (BaseClient [ httpx . AsyncClient ] ):
11401143 _client : httpx .AsyncClient
11411144 _has_custom_http_client : bool
11421145 _default_stream_cls : type [AsyncStream [Any ]] | None = None
Original file line number Diff line number Diff line change @@ -92,31 +92,31 @@ def __init__(self, request: httpx.Request) -> None:
9292
9393
9494class BadRequestError (APIStatusError ):
95- status_code : Literal [400 ] = 400
95+ status_code : Literal [400 ] = 400 # pyright: ignore[reportIncompatibleVariableOverride]
9696
9797
9898class AuthenticationError (APIStatusError ):
99- status_code : Literal [401 ] = 401
99+ status_code : Literal [401 ] = 401 # pyright: ignore[reportIncompatibleVariableOverride]
100100
101101
102102class PermissionDeniedError (APIStatusError ):
103- status_code : Literal [403 ] = 403
103+ status_code : Literal [403 ] = 403 # pyright: ignore[reportIncompatibleVariableOverride]
104104
105105
106106class NotFoundError (APIStatusError ):
107- status_code : Literal [404 ] = 404
107+ status_code : Literal [404 ] = 404 # pyright: ignore[reportIncompatibleVariableOverride]
108108
109109
110110class ConflictError (APIStatusError ):
111- status_code : Literal [409 ] = 409
111+ status_code : Literal [409 ] = 409 # pyright: ignore[reportIncompatibleVariableOverride]
112112
113113
114114class UnprocessableEntityError (APIStatusError ):
115- status_code : Literal [422 ] = 422
115+ status_code : Literal [422 ] = 422 # pyright: ignore[reportIncompatibleVariableOverride]
116116
117117
118118class RateLimitError (APIStatusError ):
119- status_code : Literal [429 ] = 429
119+ status_code : Literal [429 ] = 429 # pyright: ignore[reportIncompatibleVariableOverride]
120120
121121
122122class InternalServerError (APIStatusError ):
Original file line number Diff line number Diff line change 2929api_key = "My API Key"
3030
3131
32- def _get_params (client : BaseClient ) -> dict [str , str ]:
32+ def _get_params (client : BaseClient [ Any ] ) -> dict [str , str ]:
3333 request = client ._build_request (FinalRequestOptions (method = "get" , url = "/foo" ))
3434 url = httpx .URL (request .url )
3535 return dict (url .params )
You can’t perform that action at this time.
0 commit comments