From dad56bfc1d26ef61e90111e871af9fd0f07a0ee3 Mon Sep 17 00:00:00 2001 From: Julio Quinteros Pro Date: Fri, 6 Feb 2026 16:20:18 -0300 Subject: [PATCH] fix: address type annotation and None check suggestions - Update model parameter type to Optional[str] in both helper functions - Update return types to Tuple[Optional[str], Optional[str]] - Add explicit None check before `model in litellm.cohere_chat_models` - Add explicit None check before `_is_anthropic_text_model(model)` Addresses Greptile review suggestions. Co-Authored-By: Claude Opus 4.5 --- litellm/litellm_core_utils/get_llm_provider_logic.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.py index 8ab4ec15b07..0a569dcea34 100644 --- a/litellm/litellm_core_utils/get_llm_provider_logic.py +++ b/litellm/litellm_core_utils/get_llm_provider_logic.py @@ -34,8 +34,8 @@ def _is_azure_claude_model(model: str) -> bool: def handle_cohere_chat_model_custom_llm_provider( - model: str, custom_llm_provider: Optional[str] = None -) -> Tuple[str, Optional[str]]: + model: Optional[str], custom_llm_provider: Optional[str] = None +) -> Tuple[Optional[str], Optional[str]]: """ if user sets model = "cohere/command-r" -> use custom_llm_provider = "cohere_chat" @@ -48,7 +48,7 @@ def handle_cohere_chat_model_custom_llm_provider( """ if custom_llm_provider: - if custom_llm_provider == "cohere" and model in litellm.cohere_chat_models: + if custom_llm_provider == "cohere" and model and model in litellm.cohere_chat_models: return model, "cohere_chat" if model and "/" in model: @@ -64,8 +64,8 @@ def handle_cohere_chat_model_custom_llm_provider( def handle_anthropic_text_model_custom_llm_provider( - model: str, custom_llm_provider: Optional[str] = None -) -> Tuple[str, Optional[str]]: + model: Optional[str], custom_llm_provider: Optional[str] = None +) -> Tuple[Optional[str], Optional[str]]: """ if user sets model = "anthropic/claude-2" -> use custom_llm_provider = "anthropic_text" @@ -80,6 +80,7 @@ def handle_anthropic_text_model_custom_llm_provider( if custom_llm_provider: if ( custom_llm_provider == "anthropic" + and model and litellm.AnthropicTextConfig._is_anthropic_text_model(model) ): return model, "anthropic_text"