Skip to content

The agent engineering platform.

community[patch]: mypy ignore fix (#18483)

Smit Parmardfc4177b5067
diff --git a/libs/community/langchain_community/chat_message_histories/dynamodb.py b/libs/community/langchain_community/chat_message_histories/dynamodb.py
index 4429d2e1f1..2f1c18c45c 100644
--- a/libs/community/langchain_community/chat_message_histories/dynamodb.py
+++ b/libs/community/langchain_community/chat_message_histories/dynamodb.py
@@ -103,7 +103,7 @@ class DynamoDBChatMessageHistory(BaseChatMessageHistory):
)
@property
- def messages(self) -> List[BaseMessage]: # type: ignore
+ def messages(self) -> List[BaseMessage]:
"""Retrieve the messages from DynamoDB"""
try:
from botocore.exceptions import ClientError
@@ -129,6 +129,13 @@ class DynamoDBChatMessageHistory(BaseChatMessageHistory):
messages = messages_from_dict(items)
return messages
+ @messages.setter
+ def messages(self, messages: List[BaseMessage]) -> None:
+ raise NotImplementedError(
+ "Direct assignment to 'messages' is not allowed."
+ " Use the 'add_messages' instead."
+ )
+
def add_message(self, message: BaseMessage) -> None:
"""Append the message to the record in DynamoDB"""
try:
diff --git a/libs/community/langchain_community/chat_message_histories/elasticsearch.py b/libs/community/langchain_community/chat_message_histories/elasticsearch.py
index 4000241063..464e9e1273 100644
--- a/libs/community/langchain_community/chat_message_histories/elasticsearch.py
+++ b/libs/community/langchain_community/chat_message_histories/elasticsearch.py
@@ -143,7 +143,7 @@ class ElasticsearchChatMessageHistory(BaseChatMessageHistory):
return es_client
@property
- def messages(self) -> List[BaseMessage]: # type: ignore[override]
+ def messages(self) -> List[BaseMessage]:
"""Retrieve the messages from Elasticsearch"""
try:
from elasticsearch import ApiError
@@ -167,6 +167,13 @@ class ElasticsearchChatMessageHistory(BaseChatMessageHistory):
return messages_from_dict(items)
+ @messages.setter
+ def messages(self, messages: List[BaseMessage]) -> None:
+ raise NotImplementedError(
+ "Direct assignment to 'messages' is not allowed."
+ " Use the 'add_messages' instead."
+ )
+
def add_message(self, message: BaseMessage) -> None:
"""Add a message to the chat session in Elasticsearch"""
try: