fix(api): mypy no-redef and no-any-return errors on dev (CAR-1335)
The api typecheck job is continue-on-error but still posts a failure status that blocks merges. Three pre-existing mypy errors on dev were inherited by every PR based on it: 1. middleware/rate_limit.py: duplicate 'name already defined' for _public_limiter, _auth_limiter, _auth_strict_limiter (declared at lines 111-113 and again at 124-126). The second set is redundant because actual assignment happens inside the if/else below. 2. cache.py:43 - 'Returning Any' from .get(); the redis client's get() return type isn't narrowed to bytes|str, so the final 'return value' branch is Any. Wrap with str() to satisfy the declared str|None. 3. middleware/rate_limit.py:150 - 'Returning Any' from _get_client_ip. request.headers.get() and request.client.host are typed Any; wrap the branches with str() to match the declared str return. Refs CAR-1335. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -40,7 +40,7 @@ class CacheClient:
|
||||
return None
|
||||
if isinstance(value, bytes):
|
||||
return value.decode("utf-8", errors="replace")
|
||||
return value
|
||||
return str(value)
|
||||
|
||||
async def set(self, key: str, value: str, ttl_seconds: int = 300) -> None:
|
||||
if not self._client:
|
||||
|
||||
Reference in New Issue
Block a user