Skip to content

Commit 5eb591e

Browse files
committed
Fix Python 3.9 compatibility issues in tests
- Replace Python 3.10+ union syntax (X | Y) with Union[X, Y] - Add type ignore for BaseMessageChunk/AIMessage isinstance check - Add rich module to mypy ignore list for examples
1 parent 5bf6e8e commit 5eb591e

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

libs/oci/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ module = [
107107
"ads.*",
108108
"langchain_openai.*",
109109
"oci_openai.*",
110+
"rich.*",
110111
]
111112
ignore_missing_imports = true
112113

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"""
1414

1515
import os
16+
from typing import Union
1617

1718
import pytest
1819
from langchain_core.messages import (
@@ -406,7 +407,7 @@ def test_multi_turn_context_retention(llm):
406407
def test_long_context_handling(llm):
407408
"""Test handling of longer context windows."""
408409
# Create a conversation with multiple turns
409-
messages: list[SystemMessage | HumanMessage | AIMessage] = [
410+
messages: list[Union[SystemMessage, HumanMessage, AIMessage]] = [
410411
SystemMessage(content="You are a helpful assistant tracking a story."),
411412
]
412413

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ 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"
150+
assert isinstance(chunk, AIMessage), "Chunk should be AIMessage" # type: ignore[arg-type]
151151
chunks.append(chunk)
152152

153153
# Verify we got at least one chunk (streaming worked)

0 commit comments

Comments
 (0)