From 1343f38da97b4f26d9dcfa3fabdac01d22ebaf5e Mon Sep 17 00:00:00 2001 From: yucheng Date: Fri, 30 Oct 2026 13:12:51 -0700 Subject: [PATCH] refactor(caching): import redis exceptions directly in is_redis_scripting_unavailable Its only caller runs after a Redis call raised, so redis is always installed there, the same as the sibling helpers that import it lazily without a fallback --- litellm/caching/redis_cache.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/litellm/caching/redis_cache.py b/litellm/caching/redis_cache.py index bd22c97b1f4..a707e31ef32 100644 --- a/litellm/caching/redis_cache.py +++ b/litellm/caching/redis_cache.py @@ -456,10 +456,8 @@ def is_redis_timeout_failure(exc: BaseException) -> bool: def is_redis_scripting_unavailable(exc: BaseException) -> bool: """True when Redis refused to run a Lua script for this client: an ACL without ``@scripting``, or ``EVAL`` renamed away.""" - try: - from redis.exceptions import NoPermissionError, ResponseError - except ImportError: - return False + from redis.exceptions import NoPermissionError, ResponseError + if isinstance(exc, NoPermissionError): return "permissions to run" in str(exc) return isinstance(exc, ResponseError) and "unknown command" in str(exc).lower()