fix(lint): narrow decorator + cache override kwargs types to unblock strict budget gate

Adds parameter and return type annotations to _redis_circuit_breaker_guard
and UserApiKeyCache write overrides so ANN003/ANN202/ANN001/ANN002 totals
fall back below their ruff-strict-budget.json limits. The uv promote-staging
to-main lint gate was failing with ANN003 838 over limit 836 and ANN202
870 over limit 869; the annotations bring the counts to 834 and 868.

Co-authored-by: Krrish Dholakia <krrish-berri-2@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-08-06 06:15:09 +00:00
parent 0acca3e86a
commit 3f3254c13e
No known key found for this signature in database
2 changed files with 7 additions and 5 deletions

View file

@ -242,7 +242,9 @@ async def _run_under_circuit_breaker(
return result
def _redis_circuit_breaker_guard(method):
def _redis_circuit_breaker_guard(
method: Callable[..., Awaitable[_RedisCallResult]],
) -> Callable[..., Awaitable[_RedisCallResult]]:
"""
Decorator for RedisCache async methods.
Checks the circuit breaker before each call; records success/failure after.
@ -256,7 +258,7 @@ def _redis_circuit_breaker_guard(method):
"""
@functools.wraps(method)
async def wrapper(self, *args, **kwargs):
async def wrapper(self: "RedisCache", *args: object, **kwargs: object) -> _RedisCallResult:
return await _run_under_circuit_breaker(
self._circuit_breaker, method.__name__, lambda: method(self, *args, **kwargs)
)

View file

@ -129,17 +129,17 @@ class UserApiKeyCache(DualCache):
return None
return decoded
def set_cache(self, key, value, local_only: bool = False, **kwargs):
def set_cache(self, key, value, local_only: bool = False, **kwargs: object):
model_type: Final = cast(type[BaseModel] | None, kwargs.pop("model_type", None))
payload: Final = CacheCodec.serialize(value, model_type=model_type)
return super().set_cache(key=key, value=payload, local_only=local_only, **kwargs)
async def async_set_cache(self, key, value, local_only: bool = False, **kwargs):
async def async_set_cache(self, key, value, local_only: bool = False, **kwargs: object):
model_type: Final = cast(type[BaseModel] | None, kwargs.pop("model_type", None))
payload: Final = CacheCodec.serialize(value, model_type=model_type)
return await super().async_set_cache(key=key, value=payload, local_only=local_only, **kwargs)
async def async_set_cache_pipeline(self, cache_list: list, local_only: bool = False, **kwargs) -> None:
async def async_set_cache_pipeline(self, cache_list: list, local_only: bool = False, **kwargs: object) -> None:
"""
Batch writes with the same Codec boundary as ``async_set_cache`` without
``model_type``: ``BaseModel`` values become JSON-safe dicts; dicts/scalars unchanged.