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 = [
8
8
{ name = " OpenAI" , email = " support@openai.com" },
9
9
]
10
10
dependencies = [
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"
17
17
]
18
18
requires-python = " >= 3.7.1"
19
19
@@ -30,17 +30,17 @@ openai = "openai.cli:main"
30
30
[tool .rye ]
31
31
managed = true
32
32
dev-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"
44
44
]
45
45
46
46
[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:
315
315
return await self ._client ._request_api_list (self ._model , page = self .__class__ , options = options )
316
316
317
317
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
320
323
_version : str
321
324
_base_url : URL
322
325
max_retries : int
@@ -730,7 +733,7 @@ def _idempotency_key(self) -> str:
730
733
return f"stainless-python-retry-{ uuid .uuid4 ()} "
731
734
732
735
733
- class SyncAPIClient (BaseClient ):
736
+ class SyncAPIClient (BaseClient [ httpx . Client ] ):
734
737
_client : httpx .Client
735
738
_has_custom_http_client : bool
736
739
_default_stream_cls : type [Stream [Any ]] | None = None
@@ -1136,7 +1139,7 @@ def get_api_list(
1136
1139
return self ._request_api_list (model , page , opts )
1137
1140
1138
1141
1139
- class AsyncAPIClient (BaseClient ):
1142
+ class AsyncAPIClient (BaseClient [ httpx . AsyncClient ] ):
1140
1143
_client : httpx .AsyncClient
1141
1144
_has_custom_http_client : bool
1142
1145
_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:
92
92
93
93
94
94
class BadRequestError (APIStatusError ):
95
- status_code : Literal [400 ] = 400
95
+ status_code : Literal [400 ] = 400 # pyright: ignore[reportIncompatibleVariableOverride]
96
96
97
97
98
98
class AuthenticationError (APIStatusError ):
99
- status_code : Literal [401 ] = 401
99
+ status_code : Literal [401 ] = 401 # pyright: ignore[reportIncompatibleVariableOverride]
100
100
101
101
102
102
class PermissionDeniedError (APIStatusError ):
103
- status_code : Literal [403 ] = 403
103
+ status_code : Literal [403 ] = 403 # pyright: ignore[reportIncompatibleVariableOverride]
104
104
105
105
106
106
class NotFoundError (APIStatusError ):
107
- status_code : Literal [404 ] = 404
107
+ status_code : Literal [404 ] = 404 # pyright: ignore[reportIncompatibleVariableOverride]
108
108
109
109
110
110
class ConflictError (APIStatusError ):
111
- status_code : Literal [409 ] = 409
111
+ status_code : Literal [409 ] = 409 # pyright: ignore[reportIncompatibleVariableOverride]
112
112
113
113
114
114
class UnprocessableEntityError (APIStatusError ):
115
- status_code : Literal [422 ] = 422
115
+ status_code : Literal [422 ] = 422 # pyright: ignore[reportIncompatibleVariableOverride]
116
116
117
117
118
118
class RateLimitError (APIStatusError ):
119
- status_code : Literal [429 ] = 429
119
+ status_code : Literal [429 ] = 429 # pyright: ignore[reportIncompatibleVariableOverride]
120
120
121
121
122
122
class InternalServerError (APIStatusError ):
Original file line number Diff line number Diff line change 29
29
api_key = "My API Key"
30
30
31
31
32
- def _get_params (client : BaseClient ) -> dict [str , str ]:
32
+ def _get_params (client : BaseClient [ Any ] ) -> dict [str , str ]:
33
33
request = client ._build_request (FinalRequestOptions (method = "get" , url = "/foo" ))
34
34
url = httpx .URL (request .url )
35
35
return dict (url .params )
You can’t perform that action at this time.
0 commit comments