fix(ci): resolve mypy and check_code_and_doc_quality CI failures (#21812)

- fix(mypy): suppress [misc] type error in common_utils.py for cls.__init__ access
- fix(mypy): move type: ignore comment to correct line in test_eval.py (line 232 not 231)
- fix(mypy): suppress [misc] and pre-existing pyright errors in vertex_ai_non_gemini.py
- fix(check_licenses): strip inline comments before parsing requirements.txt lines so CVE comments don't break packaging.requirements.Requirement()
- fix(router_coverage): add _merge_tools_from_deployment and _invalidate_access_groups_cache to ignored list (private helpers tested indirectly)
This commit is contained in:
Ishaan Jaff
2026-02-21 13:08:47 -08:00
committed by GitHub
parent 22704b0176
commit 0a0768b3df
5 changed files with 13 additions and 10 deletions
+3 -2
View File
@@ -5,7 +5,7 @@ Common helpers / utils across al OpenAI endpoints
import hashlib
import json
import ssl
from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union
import httpx
import openai
@@ -24,9 +24,10 @@ from litellm.llms.custom_httpx.http_handler import (
get_ssl_configuration,
)
def _get_client_init_params(cls: type) -> List[str]:
"""Extract __init__ parameter names (excluding 'self') from a class."""
return [p for p in inspect.signature(cls.__init__).parameters if p != "self"]
return [p for p in inspect.signature(cls.__init__).parameters if p != "self"] # type: ignore[misc]
_OPENAI_INIT_PARAMS: List[str] = _get_client_init_params(OpenAI)
@@ -247,7 +247,7 @@ def completion( # noqa: PLR0915
instances = [optional_params.copy()]
instances[0]["prompt"] = prompt
instances = [
json_format.ParseDict(instance_dict, Value())
json_format.ParseDict(instance_dict, Value()) # type: ignore[misc]
for instance_dict in instances
]
# Will determine the API used based on async parameter
@@ -375,7 +375,7 @@ def completion( # noqa: PLR0915
)
llm_model = aiplatform.gapic.PredictionServiceClient(
client_options=client_options,
credentials=creds,
credentials=creds, # type: ignore[arg-type]
)
request_str += f"llm_model = aiplatform.gapic.PredictionServiceClient(client_options={client_options}, credentials=...)\n"
endpoint_path = llm_model.endpoint_path(
@@ -441,7 +441,7 @@ def completion( # noqa: PLR0915
model_response.model = model
## CALCULATING USAGE
if model in litellm.vertex_language_models and response_obj is not None:
model_response.choices[0].finish_reason = map_finish_reason(
model_response.choices[0].finish_reason = map_finish_reason( # type: ignore[assignment]
response_obj.candidates[0].finish_reason.name
)
usage = Usage(
@@ -614,7 +614,7 @@ async def async_completion( # noqa: PLR0915
model_response.model = model
## CALCULATING USAGE
if model in litellm.vertex_language_models and response_obj is not None:
model_response.choices[0].finish_reason = map_finish_reason(
model_response.choices[0].finish_reason = map_finish_reason( # type: ignore[assignment]
response_obj.candidates[0].finish_reason.name
)
usage = Usage(
@@ -228,8 +228,8 @@ def _content_filter(category: str):
guardrail = ContentFilterGuardrail(
guardrail_name=f"{category}_eval",
categories=[ # type: ignore[arg-type,list-item]
{
categories=[
{ # type: ignore[list-item]
"category": category,
"enabled": True,
"action": "BLOCK",
+2 -2
View File
@@ -214,9 +214,9 @@ class LicenseChecker:
try:
with open(requirements_file) as f:
requirements = [
Requirement(line.strip())
Requirement(line.split("#")[0].strip())
for line in f
if line.strip() and not line.startswith("#")
if line.split("#")[0].strip() and not line.startswith("#")
]
except Exception as e:
print(f"Error parsing {requirements_file}: {str(e)}")
@@ -78,6 +78,8 @@ ignored_function_names = [
"__init__",
"avector_store_create", # Tested via proxy vector_store_endpoints (files lack "router" in name)
"_override_vector_store_methods_for_router", # No-op placeholder, called during Router init
"_merge_tools_from_deployment", # Tested indirectly via _update_kwargs_with_deployment (test files lack "router" in name)
"_invalidate_access_groups_cache", # Tested indirectly via set_model_list, upsert_model etc. (test files lack "router" in name)
]