Skip to content

Commit 8d62f69

Browse files
chore(internal): bump pyright (#145)
1 parent 403eb82 commit 8d62f69

File tree

6 files changed

+35
-30
lines changed

6 files changed

+35
-30
lines changed

pyproject.toml

+17-17
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ authors = [
88
{ name = "Finch", email = "[email protected]" },
99
]
1010
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-
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+
1717
]
1818
requires-python = ">= 3.7"
1919

@@ -28,17 +28,17 @@ Repository = "https://github.com/Finch-API/finch-api-python"
2828
[tool.rye]
2929
managed = true
3030
dev-dependencies = [
31-
"pyright==1.1.326",
32-
"mypy==1.4.1",
33-
"black==23.3.0",
34-
"respx==0.19.2",
35-
"pytest==7.1.1",
36-
"pytest-asyncio==0.21.1",
37-
"ruff==0.0.282",
38-
"isort==5.10.1",
39-
"time-machine==2.9.0",
40-
"nox==2023.4.22",
41-
31+
"pyright==1.1.332",
32+
"mypy==1.4.1",
33+
"black==23.3.0",
34+
"respx==0.19.2",
35+
"pytest==7.1.1",
36+
"pytest-asyncio==0.21.1",
37+
"ruff==0.0.282",
38+
"isort==5.10.1",
39+
"time-machine==2.9.0",
40+
"nox==2023.4.22",
41+
4242
]
4343

4444
[tool.rye.scripts]

requirements-dev.lock

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ pluggy==1.3.0
3636
py==1.11.0
3737
pydantic==2.4.2
3838
pydantic-core==2.10.1
39-
pyright==1.1.326
39+
pyright==1.1.332
4040
pytest==7.1.1
4141
pytest-asyncio==0.21.1
4242
python-dateutil==2.8.2
4343
respx==0.19.2
44+
rfc3986==1.5.0
4445
ruff==0.0.282
4546
six==1.16.0
4647
sniffio==1.3.0

requirements.lock

+1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ httpx==0.23.0
1818
idna==3.4
1919
pydantic==2.4.2
2020
pydantic-core==2.10.1
21+
rfc3986==1.5.0
2122
sniffio==1.3.0
2223
typing-extensions==4.8.0

src/finch/_base_client.py

+7-4
Original file line numberDiff line numberDiff 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

src/finch/_exceptions.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -76,31 +76,31 @@ def __init__(self, request: httpx.Request) -> None:
7676

7777

7878
class BadRequestError(APIStatusError):
79-
status_code: Literal[400] = 400
79+
status_code: Literal[400] = 400 # pyright: ignore[reportIncompatibleVariableOverride]
8080

8181

8282
class AuthenticationError(APIStatusError):
83-
status_code: Literal[401] = 401
83+
status_code: Literal[401] = 401 # pyright: ignore[reportIncompatibleVariableOverride]
8484

8585

8686
class PermissionDeniedError(APIStatusError):
87-
status_code: Literal[403] = 403
87+
status_code: Literal[403] = 403 # pyright: ignore[reportIncompatibleVariableOverride]
8888

8989

9090
class NotFoundError(APIStatusError):
91-
status_code: Literal[404] = 404
91+
status_code: Literal[404] = 404 # pyright: ignore[reportIncompatibleVariableOverride]
9292

9393

9494
class ConflictError(APIStatusError):
95-
status_code: Literal[409] = 409
95+
status_code: Literal[409] = 409 # pyright: ignore[reportIncompatibleVariableOverride]
9696

9797

9898
class UnprocessableEntityError(APIStatusError):
99-
status_code: Literal[422] = 422
99+
status_code: Literal[422] = 422 # pyright: ignore[reportIncompatibleVariableOverride]
100100

101101

102102
class RateLimitError(APIStatusError):
103-
status_code: Literal[429] = 429
103+
status_code: Literal[429] = 429 # pyright: ignore[reportIncompatibleVariableOverride]
104104

105105

106106
class InternalServerError(APIStatusError):

tests/test_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
access_token = "My Access Token"
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)

0 commit comments

Comments
 (0)