Skip to content

Commit 4185b91

Browse files
committed
Fix mypy type errors for bind() return type narrowing
Add type ignore comments to resolve mypy errors where super().bind() returns Runnable[..., BaseMessage] but chat models narrow to AIMessage. These are safe ignores - the runtime types are correct.
1 parent 20a1327 commit 4185b91

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

libs/oci/langchain_oci/chat_models/oci_data_science.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ def bind_tools(
778778
formatted_tools = [convert_to_openai_tool(tool) for tool in tools]
779779
if tool_choice is not None:
780780
kwargs["tool_choice"] = tool_choice
781-
return super().bind(tools=formatted_tools, **kwargs)
781+
return super().bind(tools=formatted_tools, **kwargs) # type: ignore[return-value]
782782

783783

784784
class ChatOCIModelDeploymentVLLM(ChatOCIModelDeployment):

libs/oci/langchain_oci/chat_models/oci_generative_ai.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ def bind_tools(
12851285
)
12861286
kwargs["is_parallel_tool_calls"] = True
12871287

1288-
return super().bind(tools=formatted_tools, **kwargs)
1288+
return super().bind(tools=formatted_tools, **kwargs) # type: ignore[return-value]
12891289

12901290
def with_structured_output(
12911291
self,
@@ -1358,7 +1358,7 @@ def with_structured_output(
13581358
key_name=tool_name, first_tool_only=True
13591359
)
13601360
elif method == "json_mode":
1361-
llm = self.bind(response_format={"type": "JSON_OBJECT"})
1361+
llm = self.bind(response_format={"type": "JSON_OBJECT"}) # type: ignore[assignment]
13621362
output_parser = (
13631363
PydanticOutputParser(pydantic_object=schema)
13641364
if is_pydantic_schema
@@ -1382,7 +1382,7 @@ def with_structured_output(
13821382
json_schema=response_json_schema
13831383
)
13841384

1385-
llm = self.bind(response_format=response_format_obj)
1385+
llm = self.bind(response_format=response_format_obj) # type: ignore[assignment]
13861386
if is_pydantic_schema:
13871387
output_parser = PydanticOutputParser(pydantic_object=schema)
13881388
else:

0 commit comments

Comments
 (0)