diff --git a/libs/genai/langchain_google_genai/_function_utils.py b/libs/genai/langchain_google_genai/_function_utils.py index 3b0a9259..f2ddf8ee 100644 --- a/libs/genai/langchain_google_genai/_function_utils.py +++ b/libs/genai/langchain_google_genai/_function_utils.py @@ -147,7 +147,7 @@ def convert_to_genai_function_declarations( tools: Sequence[_ToolsType], ) -> gapic.Tool: if not isinstance(tools, collections.abc.Sequence): - logger.warning( + logger.warning( # type: ignore[unreachable] "convert_to_genai_function_declarations expects a Sequence " "and not a single tool." ) diff --git a/libs/genai/langchain_google_genai/_genai_extension.py b/libs/genai/langchain_google_genai/_genai_extension.py index 071e481b..44c508e7 100644 --- a/libs/genai/langchain_google_genai/_genai_extension.py +++ b/libs/genai/langchain_google_genai/_genai_extension.py @@ -21,7 +21,7 @@ from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from google.api_core import gapic_v1 -from google.auth import credentials, exceptions # type: ignore +from google.auth import credentials, exceptions from google.protobuf import timestamp_pb2 _logger = logging.getLogger(__name__) diff --git a/libs/genai/langchain_google_genai/chat_models.py b/libs/genai/langchain_google_genai/chat_models.py index 85032191..cb96c913 100644 --- a/libs/genai/langchain_google_genai/chat_models.py +++ b/libs/genai/langchain_google_genai/chat_models.py @@ -214,7 +214,7 @@ async def _achat_with_retry(generation_method: Callable, **kwargs: Any) -> Any: Any: The result from the chat generation method. """ retry_decorator = _create_retry_decorator() - from google.api_core.exceptions import InvalidArgument # type: ignore + from google.api_core.exceptions import InvalidArgument @retry_decorator async def _achat_with_retry(**kwargs: Any) -> Any: @@ -1232,9 +1232,7 @@ def bind_tools( genai_tools = [tool_to_dict(convert_to_genai_function_declarations(tools))] if tool_choice: all_names = [ - f["name"] # type: ignore[index] - for t in genai_tools - for f in t["function_declarations"] + f["name"] for t in genai_tools for f in t["function_declarations"] ] tool_config = _tool_choice_to_tool_config(tool_choice, all_names) return self.bind(tools=genai_tools, tool_config=tool_config, **kwargs) @@ -1248,4 +1246,4 @@ def _get_tool_name( tool: Union[ToolDict, GoogleTool], ) -> str: genai_tool = tool_to_dict(convert_to_genai_function_declarations([tool])) - return [f["name"] for f in genai_tool["function_declarations"]][0] # type: ignore[index] + return [f["name"] for f in genai_tool["function_declarations"]][0] diff --git a/libs/genai/tests/unit_tests/test_function_utils.py b/libs/genai/tests/unit_tests/test_function_utils.py index 786ad9f5..30ad9360 100644 --- a/libs/genai/tests/unit_tests/test_function_utils.py +++ b/libs/genai/tests/unit_tests/test_function_utils.py @@ -37,7 +37,7 @@ def sum_two_numbers(a: float, b: float) -> str: """ return str(a + b) - schema = convert_to_genai_function_declarations([sum_two_numbers]) # type: ignore + schema = convert_to_genai_function_declarations([sum_two_numbers]) function_declaration = schema.function_declarations[0] assert function_declaration.name == "sum_two_numbers" assert function_declaration.parameters @@ -48,7 +48,7 @@ def do_something_optional(a: float, b: float = 0) -> str: """Some description""" return str(a + b) - schema = convert_to_genai_function_declarations([do_something_optional]) # type: ignore + schema = convert_to_genai_function_declarations([do_something_optional]) function_declaration = schema.function_declarations[0] assert function_declaration.name == "do_something_optional" assert function_declaration.parameters