From 2e1e3361a1f79874c5ebcea8631964a985857b0a Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Tue, 14 Oct 2025 00:22:01 -0500 Subject: [PATCH] CLAUDE: Fix type annotations in CacheManager for JSON-serializable types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- utils/cache.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/utils/cache.py b/utils/cache.py index a3ed84f..9f8eee6 100644 --- a/utils/cache.py +++ b/utils/cache.py @@ -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,15 +108,15 @@ 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. - + Args: 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()