Skip to content

Commit

Permalink
Cleanup mypy errors from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Obs01ete committed Jul 3, 2023
1 parent 04f4496 commit be1d700
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion camel/messages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def to_openai_assistant_message(self) -> OpenAIAssistantMessage:
"""
return {"role": "assistant", "content": self.content}

def to_dict(self) -> Dict:
def to_dict(self) -> Dict[str, Any]:
r"""Converts the message to a dictionary.
Returns:
Expand Down
14 changes: 8 additions & 6 deletions test/messages/test_chat_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
from typing import Any, Dict

import pytest

from camel.messages import BaseMessage
Expand Down Expand Up @@ -59,12 +61,12 @@ def test_chat_message(chat_message: BaseMessage) -> None:
assert chat_message.content == content

dictionary = chat_message.to_dict()
assert dictionary == {
reference_dict: Dict[str, Any] = {
"role_name": role_name,
"role_type": role_type.name,
**(meta_dict or {}),
"content": content,
}
assert dictionary == reference_dict


def test_assistant_chat_message(assistant_chat_message: BaseMessage) -> None:
Expand All @@ -79,12 +81,12 @@ def test_assistant_chat_message(assistant_chat_message: BaseMessage) -> None:
assert assistant_chat_message.content == content

dictionary = assistant_chat_message.to_dict()
assert dictionary == {
reference_dict: Dict[str, Any] = {
"role_name": role_name,
"role_type": role_type.name,
**(meta_dict or {}),
"content": content,
}
assert dictionary == reference_dict


def test_user_chat_message(user_chat_message: BaseMessage) -> None:
Expand All @@ -99,9 +101,9 @@ def test_user_chat_message(user_chat_message: BaseMessage) -> None:
assert user_chat_message.content == content

dictionary = user_chat_message.to_dict()
assert dictionary == {
reference_dict: Dict[str, Any] = {
"role_name": role_name,
"role_type": role_type.name,
**(meta_dict or {}),
"content": content,
}
assert dictionary == reference_dict

0 comments on commit be1d700

Please sign in to comment.