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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016SxQ2jq4B4KLGwPoLgfHye
This commit is contained in:
lzhan011 2026-10-10 00:32:52 -05:00
parent aa97d2929e
commit 48890aba24

View file

@ -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,