mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-12 08:42:18 +00:00
style(cache): give the deferred import's noqa a reason, as the gate requires
`lint` was still red after the format fix, on a different rule this time:
FAIL: LIT-rule totals exceed their limit (base 1238cfe90f):
LIT003: total 263 over limit 261 (this change added 1)
litellm/_service_logger.py:345
LIT003 is `scripts/check_type_discipline.py`'s "noqa requires rule codes or a
reason". The deferred import carried `# noqa: PLC0415` with no reason, so it
counted against the budget; it now says why the import is deferred (a
module-scope import would be circular, since redis_cache imports this module).
Two things worth recording, both found by running the gate rather than guessing:
* A first attempt put the explanation on its own comment line above the import.
That line contained the word "noqa", which `scan_comments` reads as a *bare*
suppression -- so the explanatory comment created a second LIT003 instead of
clearing the first. The reason has to live on the suppression line itself.
* `ruff check` then wanted I001 on the longer line, and its fix wraps the
import in parentheses with the comment on the imported name.
`ruff format --check`, `ruff check` and the LIT003 scan are all clean on the
three files now, and tests/unit/caching/test_redis_cache.py still reports
100 passed.
This commit is contained in:
parent
eca4d13c41
commit
68e93eae6a
1 changed files with 3 additions and 1 deletions
|
|
@ -342,7 +342,9 @@ class ServiceLogging(CustomLogger):
|
|||
# than at each call site: `redis_cache` hands this hook an exception
|
||||
# from ~16 places and a new one must not be able to leak by being
|
||||
# written without the redaction.
|
||||
from litellm.caching.redis_cache import redact_redis_error # noqa: PLC0415
|
||||
from litellm.caching.redis_cache import (
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue