CLAUDE: Fix type annotations in CacheManager for JSON-serializable types
Update CacheManager.get() and CacheManager.set() type annotations to accept Any JSON-serializable type (dict, list, str, int, bool, None) instead of just dict. This fixes type checker warnings in base_service.py where lists are cached for API responses. The runtime behavior was already correct, this just aligns the type hints with actual usage. Changes: - CacheManager.get() return type: Optional[dict] -> Optional[Any] - CacheManager.set() data param: dict -> Any - Updated docstrings to clarify JSON-serializable types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
68c30e565b
commit
2e1e3361a1
@ -4,7 +4,7 @@ Redis caching utilities for Discord Bot v2.0
|
||||
Provides optional Redis caching functionality for API responses.
|
||||
"""
|
||||
import logging
|
||||
from typing import Optional
|
||||
from typing import Optional, Any
|
||||
import json
|
||||
|
||||
try:
|
||||
@ -108,7 +108,7 @@ class CacheManager:
|
||||
"""
|
||||
return f"{prefix}:{identifier}"
|
||||
|
||||
async def get(self, key: str) -> Optional[dict]:
|
||||
async def get(self, key: str) -> Optional[Any]:
|
||||
"""
|
||||
Get cached data.
|
||||
|
||||
@ -116,7 +116,7 @@ class CacheManager:
|
||||
key: Cache key
|
||||
|
||||
Returns:
|
||||
Cached data as dict or None if not found/error
|
||||
Cached data (any JSON-serializable type) or None if not found/error
|
||||
"""
|
||||
client = await self._get_client()
|
||||
if not client:
|
||||
@ -134,13 +134,13 @@ class CacheManager:
|
||||
logger.debug(f"Cache miss: {key}")
|
||||
return None
|
||||
|
||||
async def set(self, key: str, data: dict, ttl: Optional[int] = None) -> None:
|
||||
async def set(self, key: str, data: Any, ttl: Optional[int] = None) -> None:
|
||||
"""
|
||||
Set cached data.
|
||||
|
||||
Args:
|
||||
key: Cache key
|
||||
data: Data to cache (must be JSON serializable)
|
||||
data: Data to cache (any JSON-serializable type: dict, list, str, int, bool, None)
|
||||
ttl: Time-to-live override (uses default if None)
|
||||
"""
|
||||
client = await self._get_client()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user