Skip to content

Commit

Permalink
chore: update SDK settings (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Apr 17, 2024
1 parent f8a86e8 commit 7b9b768
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
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
3 changes: 1 addition & 2 deletions src/riza/_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
2 changes: 1 addition & 1 deletion src/riza/_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
1 change: 1 addition & 0 deletions src/riza/_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
10 changes: 10 additions & 0 deletions src/riza/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,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]

0 comments on commit 7b9b768

Please sign in to comment.