Skip to content

Commit d728f28

Browse files
committed
Add unused-ignore to type ignores for cross-version LangChain compatibility
These type ignores are needed for Python 3.9 + LangChain 0.3.x (real type errors) but appear unused in Python 3.10+ + LangChain 1.x. Adding unused-ignore suppresses the warning while keeping warn_unused_ignores=true as requested by reviewer.
1 parent c2be785 commit d728f28

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
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
@@ -780,7 +780,7 @@ def bind_tools(
780780
formatted_tools = [convert_to_openai_tool(tool) for tool in tools]
781781
if tool_choice is not None:
782782
kwargs["tool_choice"] = tool_choice
783-
return super().bind(tools=formatted_tools, **kwargs)
783+
return super().bind(tools=formatted_tools, **kwargs) # type: ignore[return-value, unused-ignore]
784784

785785

786786
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
@@ -1287,7 +1287,7 @@ def bind_tools(
12871287
)
12881288
kwargs["is_parallel_tool_calls"] = True
12891289

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

12921292
def with_structured_output(
12931293
self,
@@ -1360,7 +1360,7 @@ def with_structured_output(
13601360
key_name=tool_name, first_tool_only=True
13611361
)
13621362
elif method == "json_mode":
1363-
llm = self.bind(response_format={"type": "JSON_OBJECT"})
1363+
llm = self.bind(response_format={"type": "JSON_OBJECT"}) # type: ignore[assignment, unused-ignore]
13641364
output_parser = (
13651365
PydanticOutputParser(pydantic_object=schema)
13661366
if is_pydantic_schema
@@ -1384,7 +1384,7 @@ def with_structured_output(
13841384
json_schema=response_json_schema
13851385
)
13861386

1387-
llm = self.bind(response_format=response_format_obj)
1387+
llm = self.bind(response_format=response_format_obj) # type: ignore[assignment, unused-ignore]
13881388
if is_pydantic_schema:
13891389
output_parser = PydanticOutputParser(pydantic_object=schema)
13901390
else:

libs/oci/tests/integration_tests/chat_models/test_openai_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ def test_openai_streaming(openai_config: dict):
147147

148148
chunks = []
149149
for chunk in chat.stream([HumanMessage(content="Say hello")]):
150-
assert isinstance(chunk, AIMessage), "Chunk should be AIMessage"
151-
chunks.append(chunk)
150+
assert isinstance(chunk, AIMessage), "Chunk should be AIMessage" # type: ignore[unreachable, unused-ignore]
151+
chunks.append(chunk) # type: ignore[unreachable, unused-ignore]
152152

153153
# Verify we got at least one chunk (streaming worked)
154154
assert len(chunks) > 0, "Should receive at least one chunk"

0 commit comments

Comments
 (0)