Skip to content

release: 0.20.1 #353

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 4 commits into from
Apr 23, 2024
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.20.0"
".": "0.20.1"
}
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.20.1 (2024-04-18)

Full Changelog: [v0.20.0...v0.20.1](https://github.com/Finch-API/finch-api-python/compare/v0.20.0...v0.20.1)

### Chores

* **internal:** add lru_cache helper function ([#352](https://github.com/Finch-API/finch-api-python/issues/352)) ([2856451](https://github.com/Finch-API/finch-api-python/commit/2856451e956fa7bd70ddc9ff58cd1c7dba01f616))
* **internal:** ban usage of lru_cache ([#354](https://github.com/Finch-API/finch-api-python/issues/354)) ([d909f7d](https://github.com/Finch-API/finch-api-python/commit/d909f7dd0dba483a4ce1fd4dbd842a5649091f99))
* **internal:** bump pyright to 1.1.359 ([#355](https://github.com/Finch-API/finch-api-python/issues/355)) ([a489290](https://github.com/Finch-API/finch-api-python/commit/a489290f45562abf37ec58e01c911ab8c76dcf11))

## 0.20.0 (2024-04-12)

Full Changelog: [v0.19.1...v0.20.0](https://github.com/Finch-API/finch-api-python/compare/v0.19.1...v0.20.0)
Expand Down
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "finch-api"
version = "0.20.0"
version = "0.20.1"
description = "The official Python library for the Finch API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -48,7 +48,7 @@ Repository = "https://github.com/Finch-API/finch-api-python"
managed = true
# version pins are in requirements-dev.lock
dev-dependencies = [
"pyright",
"pyright>=1.1.359",
"mypy",
"respx",
"pytest",
Expand Down Expand Up @@ -161,7 +161,9 @@ select = [
"T201",
"T203",
# misuse of typing.TYPE_CHECKING
"TCH004"
"TCH004",
# import rules
"TID251",
]
ignore = [
# mutable defaults
Expand All @@ -177,6 +179,9 @@ ignore-init-module-imports = true
[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead"

[tool.ruff.lint.isort]
length-sort = true
length-sort-straight = true
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pydantic==2.4.2
# via finch-api
pydantic-core==2.10.1
# via pydantic
pyright==1.1.353
pyright==1.1.359
pytest==7.1.1
# via pytest-asyncio
pytest-asyncio==0.21.1
Expand Down
3 changes: 1 addition & 2 deletions src/finch/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
cast,
overload,
)
from functools import lru_cache
from typing_extensions import Literal, override, get_origin

import anyio
Expand Down Expand Up @@ -61,7 +60,7 @@
RequestOptions,
ModelBuilderProtocol,
)
from ._utils import is_dict, is_list, is_given, is_mapping
from ._utils import is_dict, is_list, is_given, lru_cache, is_mapping
from ._compat import model_copy, model_dump
from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
from ._response import (
Expand Down
4 changes: 2 additions & 2 deletions src/finch/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import inspect
from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast
from datetime import date, datetime
from functools import lru_cache
from typing_extensions import (
Unpack,
Literal,
Expand Down Expand Up @@ -37,6 +36,7 @@
PropertyInfo,
is_list,
is_given,
lru_cache,
is_mapping,
parse_date,
coerce_boolean,
Expand Down Expand Up @@ -378,7 +378,7 @@ def construct_type(*, value: object, type_: object) -> object:

# unwrap `Annotated[T, ...]` -> `T`
if is_annotated_type(type_):
meta = get_args(type_)[1:]
meta: tuple[Any, ...] = get_args(type_)[1:]
type_ = extract_type_arg(type_, 0)
else:
meta = tuple()
Expand Down
1 change: 1 addition & 0 deletions src/finch/_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
is_list as is_list,
is_given as is_given,
is_tuple as is_tuple,
lru_cache as lru_cache,
is_mapping as is_mapping,
is_tuple_t as is_tuple_t,
parse_date as parse_date,
Expand Down
12 changes: 12 additions & 0 deletions src/finch/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ def wrapper(*args: object, **kwargs: object) -> object:
)
msg = f"Missing required arguments; Expected either {variations} arguments to be given"
else:
assert len(variants) > 0

# TODO: this error message is not deterministic
missing = list(set(variants[0]) - given_params)
if len(missing) > 1:
Expand Down Expand Up @@ -389,3 +391,13 @@ def get_async_library() -> str:
return sniffio.current_async_library()
except Exception:
return "false"


def lru_cache(*, maxsize: int | None = 128) -> Callable[[CallableT], CallableT]:
"""A version of functools.lru_cache that retains the type signature
for the wrapped function arguments.
"""
wrapper = functools.lru_cache( # noqa: TID251
maxsize=maxsize,
)
return cast(Any, wrapper) # type: ignore[no-any-return]
2 changes: 1 addition & 1 deletion src/finch/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "finch"
__version__ = "0.20.0" # x-release-please-version
__version__ = "0.20.1" # x-release-please-version