From 725c5648aad13abe4929a04f52233412461c22aa Mon Sep 17 00:00:00 2001 From: Jaeyeon Kim Date: Thu, 5 Mar 2026 22:46:44 +0900 Subject: [PATCH] refactor: clean up _invoke_callback_setup_proxy - Remove redundant hasattr check (setup_proxy is defined on base class) - Remove inline import (CustomLogger already imported at module level) - Add note about call timing (before DB init) in docstring Co-Authored-By: Claude Opus 4.6 --- litellm/proxy/proxy_server.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index c52cae889f3..fe810f74a78 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -762,11 +762,12 @@ def _invoke_callback_setup_proxy(app: FastAPI) -> None: This gives callbacks an opportunity to interact with the FastAPI app during startup, e.g., to add middleware or mount additional routes. - """ - from litellm.integrations.custom_logger import CustomLogger + Note: Called after config load but before DB initialization, so callbacks + should not depend on prisma_client being available. + """ for callback in litellm.callbacks: - if isinstance(callback, CustomLogger) and hasattr(callback, "setup_proxy"): + if isinstance(callback, CustomLogger): try: callback.setup_proxy(app) except Exception as e: