From 99c424f524ab4ce5871d2924ac45407c48fb1f80 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Fri, 20 Oct 2023 12:44:18 +0000 Subject: [PATCH] chore(internal): bump pyright --- pyproject.toml | 34 +++++++++++++++++----------------- requirements-dev.lock | 3 ++- requirements.lock | 1 + src/finch/_base_client.py | 11 +++++++---- src/finch/_exceptions.py | 14 +++++++------- tests/test_client.py | 2 +- 6 files changed, 35 insertions(+), 30 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b5d9e06d..2f9cae5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,12 +8,12 @@ authors = [ { name = "Finch", email = "founders@tryfinch.com" }, ] dependencies = [ - "httpx>=0.23.0, <1", - "pydantic>=1.9.0, <3", - "typing-extensions>=4.5, <5", - "anyio>=3.5.0, <4", - "distro>=1.7.0, <2", - + "httpx>=0.23.0, <1", + "pydantic>=1.9.0, <3", + "typing-extensions>=4.5, <5", + "anyio>=3.5.0, <4", + "distro>=1.7.0, <2", + ] requires-python = ">= 3.7" @@ -28,17 +28,17 @@ Repository = "https://github.com/Finch-API/finch-api-python" [tool.rye] managed = true dev-dependencies = [ - "pyright==1.1.326", - "mypy==1.4.1", - "black==23.3.0", - "respx==0.19.2", - "pytest==7.1.1", - "pytest-asyncio==0.21.1", - "ruff==0.0.282", - "isort==5.10.1", - "time-machine==2.9.0", - "nox==2023.4.22", - + "pyright==1.1.332", + "mypy==1.4.1", + "black==23.3.0", + "respx==0.19.2", + "pytest==7.1.1", + "pytest-asyncio==0.21.1", + "ruff==0.0.282", + "isort==5.10.1", + "time-machine==2.9.0", + "nox==2023.4.22", + ] [tool.rye.scripts] diff --git a/requirements-dev.lock b/requirements-dev.lock index 16b88e10..947bd067 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -36,11 +36,12 @@ pluggy==1.3.0 py==1.11.0 pydantic==2.4.2 pydantic-core==2.10.1 -pyright==1.1.326 +pyright==1.1.332 pytest==7.1.1 pytest-asyncio==0.21.1 python-dateutil==2.8.2 respx==0.19.2 +rfc3986==1.5.0 ruff==0.0.282 six==1.16.0 sniffio==1.3.0 diff --git a/requirements.lock b/requirements.lock index a0736c81..0c8c2c2e 100644 --- a/requirements.lock +++ b/requirements.lock @@ -18,5 +18,6 @@ httpx==0.23.0 idna==3.4 pydantic==2.4.2 pydantic-core==2.10.1 +rfc3986==1.5.0 sniffio==1.3.0 typing-extensions==4.8.0 diff --git a/src/finch/_base_client.py b/src/finch/_base_client.py index 05c11810..c49cc042 100644 --- a/src/finch/_base_client.py +++ b/src/finch/_base_client.py @@ -315,8 +315,11 @@ async def get_next_page(self: AsyncPageT) -> AsyncPageT: return await self._client._request_api_list(self._model, page=self.__class__, options=options) -class BaseClient: - _client: httpx.Client | httpx.AsyncClient +_HttpxClientT = TypeVar("_HttpxClientT", bound=Union[httpx.Client, httpx.AsyncClient]) + + +class BaseClient(Generic[_HttpxClientT]): + _client: _HttpxClientT _version: str _base_url: URL max_retries: int @@ -730,7 +733,7 @@ def _idempotency_key(self) -> str: return f"stainless-python-retry-{uuid.uuid4()}" -class SyncAPIClient(BaseClient): +class SyncAPIClient(BaseClient[httpx.Client]): _client: httpx.Client _has_custom_http_client: bool _default_stream_cls: type[Stream[Any]] | None = None @@ -1136,7 +1139,7 @@ def get_api_list( return self._request_api_list(model, page, opts) -class AsyncAPIClient(BaseClient): +class AsyncAPIClient(BaseClient[httpx.AsyncClient]): _client: httpx.AsyncClient _has_custom_http_client: bool _default_stream_cls: type[AsyncStream[Any]] | None = None diff --git a/src/finch/_exceptions.py b/src/finch/_exceptions.py index 53277adc..8d69569f 100644 --- a/src/finch/_exceptions.py +++ b/src/finch/_exceptions.py @@ -76,31 +76,31 @@ def __init__(self, request: httpx.Request) -> None: class BadRequestError(APIStatusError): - status_code: Literal[400] = 400 + status_code: Literal[400] = 400 # pyright: ignore[reportIncompatibleVariableOverride] class AuthenticationError(APIStatusError): - status_code: Literal[401] = 401 + status_code: Literal[401] = 401 # pyright: ignore[reportIncompatibleVariableOverride] class PermissionDeniedError(APIStatusError): - status_code: Literal[403] = 403 + status_code: Literal[403] = 403 # pyright: ignore[reportIncompatibleVariableOverride] class NotFoundError(APIStatusError): - status_code: Literal[404] = 404 + status_code: Literal[404] = 404 # pyright: ignore[reportIncompatibleVariableOverride] class ConflictError(APIStatusError): - status_code: Literal[409] = 409 + status_code: Literal[409] = 409 # pyright: ignore[reportIncompatibleVariableOverride] class UnprocessableEntityError(APIStatusError): - status_code: Literal[422] = 422 + status_code: Literal[422] = 422 # pyright: ignore[reportIncompatibleVariableOverride] class RateLimitError(APIStatusError): - status_code: Literal[429] = 429 + status_code: Literal[429] = 429 # pyright: ignore[reportIncompatibleVariableOverride] class InternalServerError(APIStatusError): diff --git a/tests/test_client.py b/tests/test_client.py index 762e7bc8..b5acca48 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -29,7 +29,7 @@ access_token = "My Access Token" -def _get_params(client: BaseClient) -> dict[str, str]: +def _get_params(client: BaseClient[Any]) -> dict[str, str]: request = client._build_request(FinalRequestOptions(method="get", url="/foo")) url = httpx.URL(request.url) return dict(url.params)