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]

chore(types): type the dict-shim helpers to offset the budget gate

Kent6a940ef3f4c3
diff --git a/litellm/types/router.py b/litellm/types/router.py
index 87e3364ac7e..75370d94895 100644
--- a/litellm/types/router.py
+++ b/litellm/types/router.py
@@ -154,19 +154,19 @@ class ModelInfo(BaseModel):
model_config = ConfigDict(extra="allow")
- def __contains__(self, key):
+ def __contains__(self, key: str) -> bool:
# Define custom behavior for the 'in' operator
return hasattr(self, key)
- def get(self, key, default=None):
+ def get(self, key: str, default=None):
# Custom .get() method to access attributes with a default value if the attribute doesn't exist
return getattr(self, key, default)
- def __getitem__(self, key):
+ def __getitem__(self, key: str):
# Allow dictionary-style access to attributes
return getattr(self, key)
- def __setitem__(self, key, value):
+ def __setitem__(self, key: str, value) -> None:
# Allow dictionary-style assignment of attributes
setattr(self, key, value)
@@ -303,19 +303,19 @@ class GenericLiteLLMParams(CredentialLiteLLMParams, CustomPricingLiteLLMParams):
return filtered
return data
- def __contains__(self, key):
+ def __contains__(self, key: str) -> bool:
# Define custom behavior for the 'in' operator
return hasattr(self, key)
- def get(self, key, default=None):
+ def get(self, key: str, default=None):
# Custom .get() method to access attributes with a default value if the attribute doesn't exist
return getattr(self, key, default)
- def __getitem__(self, key):
+ def __getitem__(self, key: str):
# Allow dictionary-style access to attributes
return getattr(self, key)
- def __setitem__(self, key, value):
+ def __setitem__(self, key: str, value) -> None:
# Allow dictionary-style assignment of attributes
setattr(self, key, value)
@@ -328,19 +328,19 @@ class LiteLLM_Params(GenericLiteLLMParams):
model: str
model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)
- def __contains__(self, key):
+ def __contains__(self, key: str) -> bool:
# Define custom behavior for the 'in' operator
return hasattr(self, key)
- def get(self, key, default=None):
+ def get(self, key: str, default=None):
# Custom .get() method to access attributes with a default value if the attribute doesn't exist
return getattr(self, key, default)
- def __getitem__(self, key):
+ def __getitem__(self, key: str):
# Allow dictionary-style access to attributes
return getattr(self, key)
- def __setitem__(self, key, value):
+ def __setitem__(self, key: str, value) -> None:
# Allow dictionary-style assignment of attributes
setattr(self, key, value)
@@ -473,19 +473,19 @@ class Deployment(BaseModel):
# if using pydantic v1
return self.dict(**kwargs)
- def __contains__(self, key):
+ def __contains__(self, key: str) -> bool:
# Define custom behavior for the 'in' operator
return hasattr(self, key)
- def get(self, key, default=None):
+ def get(self, key: str, default=None):
# Custom .get() method to access attributes with a default value if the attribute doesn't exist
return getattr(self, key, default)
- def __getitem__(self, key):
+ def __getitem__(self, key: str):
# Allow dictionary-style access to attributes
return getattr(self, key)
- def __setitem__(self, key, value):
+ def __setitem__(self, key: str, value) -> None:
# Allow dictionary-style assignment of attributes
setattr(self, key, value)