Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

refactor: replace fresh getattr string access and a restating comment (#45017)

devin-ai-integration[bot]7b439d913838
diff --git a/litellm/llms/sap/chat/transformation.py b/litellm/llms/sap/chat/transformation.py
index cd772449dd7..342a4ff7025 100755
--- a/litellm/llms/sap/chat/transformation.py
+++ b/litellm/llms/sap/chat/transformation.py
@@ -90,7 +90,7 @@ def _fold_message_cache_control(
return base
-def _message_role_mapping(role: str) -> type[ChatMessage]: # returns the SAP message model class, not an instance
+def _message_role_mapping(role: str) -> type[ChatMessage]:
return {
"user": SAPUserMessage,
"assistant": SAPAssistantMessage,
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
index 2f607342e22..ce23d464e68 100644
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@ -4550,7 +4550,7 @@ async def _adaptive_router_flusher_loop():
ar = tagged.strategy
# Lazy state load: covers adaptive routers registered via
# `/config/reload` after proxy boot.
- if not getattr(ar, "state_loaded", False):
+ if not ar.state_loaded:
try:
await ar.load_state_from_db(prisma_client)
finally:
diff --git a/litellm/utils.py b/litellm/utils.py
index 6c0d9064dbe..bef8aaa72c2 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -1393,10 +1393,10 @@ def _schedule_async_success_logging(
)
)
- if not getattr(logging_obj, "defer_async_logging", False):
+ if not logging_obj.defer_async_logging:
_enqueue_async_logging()
return
- if getattr(logging_obj, "enqueue_deferred_logging", None) is not None:
+ if logging_obj.enqueue_deferred_logging is not None:
return
logging_obj.enqueue_deferred_logging = _enqueue_async_logging