mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix(mypy): use type cast to resolve assignment type errors
MyPy was complaining about assigning Optional[str] to str variables. Added type casts after handler calls since model is validated to be non-None at function entry and handlers preserve it. This resolves: - litellm_core_utils/get_llm_provider_logic.py:153: error - litellm_core_utils/get_llm_provider_logic.py:157: error
This commit is contained in:
parent
dad56bfc1d
commit
21c6451335
1 changed files with 9 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Optional, Tuple
|
||||
from typing import Optional, Tuple, cast
|
||||
|
||||
import litellm
|
||||
from litellm.constants import REPLICATE_MODEL_NAME_WITH_ID_LENGTH
|
||||
|
|
@ -146,13 +146,19 @@ def get_llm_provider( # noqa: PLR0915
|
|||
return model, custom_llm_provider, dynamic_api_key, api_base
|
||||
|
||||
### Handle cases when custom_llm_provider is set to cohere/command-r-plus but it should use cohere_chat route
|
||||
model, custom_llm_provider = handle_cohere_chat_model_custom_llm_provider(
|
||||
_model, _custom_llm_provider = handle_cohere_chat_model_custom_llm_provider(
|
||||
model, custom_llm_provider
|
||||
)
|
||||
# model is validated at function entry and handlers preserve it
|
||||
model = cast(str, _model)
|
||||
custom_llm_provider = _custom_llm_provider
|
||||
|
||||
model, custom_llm_provider = handle_anthropic_text_model_custom_llm_provider(
|
||||
_model, _custom_llm_provider = handle_anthropic_text_model_custom_llm_provider(
|
||||
model, custom_llm_provider
|
||||
)
|
||||
# model is validated at function entry and handlers preserve it
|
||||
model = cast(str, _model)
|
||||
custom_llm_provider = _custom_llm_provider
|
||||
|
||||
if custom_llm_provider and (
|
||||
model.split("/")[0] != custom_llm_provider
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue