Skip to content

chore(internal): bump pyright #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ authors = [
{ name = "Finch", email = "[email protected]" },
]
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"

Expand All @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 7 additions & 4 deletions src/finch/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/finch/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down