From 48890aba2466e4f104e4630223afbb3a28539a6f Mon Sep 17 00:00:00 2001 From: lzhan011 <35493221+lzhan011@users.noreply.github.com> Date: Sat, 10 Oct 2026 00:32:52 -0500 Subject: [PATCH] style(cache): mark the redaction's error_message write as a deliberate rebind `lint` / `python` went red on the type-discipline gate after the merge: FAIL: LIT-rule totals grew past their merge-base count (base 3069a467d0): LIT010: total 16257 over ceiling 16256 (this change added 1) Localised by counting the rule per file against the merge base rather than guessing: `litellm/caching/redis_cache.py` is unchanged at 101, and `litellm/_service_logger.py` goes 10 -> 11. The one added is the redaction's write to `error_message`, which LIT010 reads as an un-`Final` assignment. `error_message` is deliberately rebound -- the three assignments above it in the same function are rebinds of the same name -- so the sanctioned suppression is `# rebind-ok`, not a `Final` annotation (which would be wrong here and would not compile). Recording a wrong turn, because it is the same shape as the LIT003 one earlier in this PR: putting `# rebind-ok: ...` on its own comment line above the statement did not clear it. The count went 11 -> 12, because the scanner reads the comment as a suppression attached to nothing and the statement is still unsuppressed. It has to sit on the statement itself. LIT010 is back to the merge-base count of 10 and LIT003 is 0 in that file; `ruff format --check` and `ruff check` are clean; tests/unit/caching/ test_redis_cache.py reports 101 passed. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_016SxQ2jq4B4KLGwPoLgfHye --- litellm/_service_logger.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/_service_logger.py b/litellm/_service_logger.py index 9f81e6bdb51..688ce641283 100644 --- a/litellm/_service_logger.py +++ b/litellm/_service_logger.py @@ -346,7 +346,9 @@ class ServiceLogging(CustomLogger): redact_redis_error, # noqa: PLC0415 # redis_cache imports this module; a module-scope import would be circular ) - error_message = redact_redis_error(error) if isinstance(error, Exception) else error_message + error_message = ( # rebind-ok: narrows the message derived above, like the three assignments that produced it + redact_redis_error(error) if isinstance(error, Exception) else error_message + ) payload: Final = ServiceLoggerPayload( is_error=True,