fix(lint): fix LIT003, add explanatory comments to exception handlers

This commit is contained in:
KnyazSh 2026-07-08 07:57:51 +00:00
parent 7a73138877
commit 8b0164d5b2
3 changed files with 13 additions and 13 deletions

View file

@ -5398,7 +5398,7 @@ def emit_standard_logging_payload(payload: StandardLoggingPayload):
if os.getenv("LITELLM_PRINT_STANDARD_LOGGING_PAYLOAD"):
try:
print(json.dumps(payload, indent=4, default=str), flush=True) # noqa: T201
except Exception as e: # noqa: BLE001
except Exception as e: # noqa: BLE001 # Safe catch-all for verbose logging
verbose_logger.exception("Error serializing standard logging payload for debug output: {}".format(str(e)))

View file

@ -93,10 +93,10 @@ class AsyncPassthroughStreamingResponse(AsyncGenerator[Any, Any]):
try:
self._response.raise_for_status()
self._iterator = _as_async_generator(self._response.aiter_bytes())
except Exception: # noqa: BLE001
except Exception: # noqa: BLE001 # Safe catch-all for cleanup logic
try:
await self._response.aclose()
except Exception: # noqa: BLE001
except Exception: # noqa: BLE001 # Safe catch-all for cleanup logic
pass
raise
return self
@ -121,7 +121,7 @@ class AsyncPassthroughStreamingResponse(AsyncGenerator[Any, Any]):
# Remove the task from the set when it finishes to avoid memory leaks
task.add_done_callback(self._background_tasks.discard)
except Exception as e: # noqa: BLE001
except Exception as e: # noqa: BLE001 # Safe catch-all for verbose logging
verbose_logger.exception(
"Failed to schedule passthrough spend-tracking flush; %d buffered chunks dropped: %s",
len(self._raw_bytes),
@ -138,11 +138,11 @@ class AsyncPassthroughStreamingResponse(AsyncGenerator[Any, Any]):
chunk = await anext(self._iterator)
self._raw_bytes.append(chunk)
return chunk
except Exception: # noqa: BLE001
except Exception: # noqa: BLE001 # Safe catch-all for cleanup logic
self._start_flush()
try:
await self._response.aclose()
except Exception: # noqa: BLE001
except Exception: # noqa: BLE001 # Safe catch-all for cleanup logic
pass
raise
@ -162,7 +162,7 @@ class AsyncPassthroughStreamingResponse(AsyncGenerator[Any, Any]):
if self._initialized:
await self._iterator.aclose()
await self._response.aclose()
except Exception: # noqa: BLE001
except Exception: # noqa: BLE001 # Safe catch-all for cleanup logic
pass
@ -195,7 +195,7 @@ class PassthroughStreamingResponse(Generator[Any, Any, Any]):
raw_bytes=self._raw_bytes,
provider_config=self._provider_config,
)
except Exception as e: # noqa: BLE001
except Exception as e: # noqa: BLE001 # Safe catch-all for verbose logging
verbose_logger.exception(
"Failed to schedule passthrough spend-tracking flush; %d buffered chunks dropped: %s",
len(self._raw_bytes),
@ -210,11 +210,11 @@ class PassthroughStreamingResponse(Generator[Any, Any, Any]):
chunk = next(self._iterator)
self._raw_bytes.append(chunk)
return chunk
except Exception: # noqa: BLE001
except Exception: # noqa: BLE001 # Safe catch-all for cleanup logic
self._start_flush()
try:
self._response.close()
except Exception: # noqa: BLE001
except Exception: # noqa: BLE001 # Safe catch-all for cleanup logic
pass
raise
@ -228,7 +228,7 @@ class PassthroughStreamingResponse(Generator[Any, Any, Any]):
self._start_flush()
try:
self._response.close()
except Exception: # noqa: BLE001
except Exception: # noqa: BLE001 # Safe catch-all for cleanup logic
pass

View file

@ -2403,7 +2403,7 @@ async def gigachat_proxy_route(
)
return result
except Exception as e: # noqa: BLE001
except Exception as e: # noqa: BLE001 # Safe catch-all for handle exception
raise await base_llm_response_processor._handle_llm_api_exception(
e=e,
user_api_key_dict=user_api_key_dict,
@ -2532,7 +2532,7 @@ async def handle_gigachat_passthrough_router_model(
return result
return result
except Exception as e: # noqa: BLE001
except Exception as e: # noqa: BLE001 # Safe catch-all for handle exception
# Use common exception handling
raise await base_llm_response_processor._handle_llm_api_exception(
e=e,