mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-19 00:58:32 +00:00
partners[lint]: run pyupgrade
to get code in line with 3.9 standards (#30781)
Using `pyupgrade` to get all `partners` code up to 3.9 standards (mostly, fixing old `typing` imports).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, List # type: ignore[import-not-found]
|
||||
from typing import Any # type: ignore[import-not-found]
|
||||
from unittest.mock import MagicMock, Mock, patch
|
||||
|
||||
import pytest # type: ignore[import-not-found]
|
||||
@@ -45,7 +45,7 @@ from langchain_huggingface.llms.huggingface_endpoint import (
|
||||
],
|
||||
)
|
||||
def test_convert_message_to_chat_message(
|
||||
message: BaseMessage, expected: Dict[str, str]
|
||||
message: BaseMessage, expected: dict[str, str]
|
||||
) -> None:
|
||||
result = _convert_message_to_chat_message(message)
|
||||
assert result == expected
|
||||
@@ -150,7 +150,7 @@ def test_create_chat_result(chat_hugging_face: Any) -> None:
|
||||
],
|
||||
)
|
||||
def test_to_chat_prompt_errors(
|
||||
chat_hugging_face: Any, messages: List[BaseMessage], expected_error: str
|
||||
chat_hugging_face: Any, messages: list[BaseMessage], expected_error: str
|
||||
) -> None:
|
||||
with pytest.raises(ValueError) as e:
|
||||
chat_hugging_face._to_chat_prompt(messages)
|
||||
@@ -194,7 +194,7 @@ def test_to_chat_prompt_valid_messages(chat_hugging_face: Any) -> None:
|
||||
],
|
||||
)
|
||||
def test_to_chatml_format(
|
||||
chat_hugging_face: Any, message: BaseMessage, expected: Dict[str, str]
|
||||
chat_hugging_face: Any, message: BaseMessage, expected: dict[str, str]
|
||||
) -> None:
|
||||
result = chat_hugging_face._to_chatml_format(message)
|
||||
assert result == expected
|
||||
@@ -207,7 +207,7 @@ def test_to_chatml_format_with_invalid_type(chat_hugging_face: Any) -> None:
|
||||
assert "Unknown message type:" in str(e.value)
|
||||
|
||||
|
||||
def tool_mock() -> Dict:
|
||||
def tool_mock() -> dict:
|
||||
return {"function": {"name": "test_tool"}}
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ def tool_mock() -> Dict:
|
||||
)
|
||||
def test_bind_tools_errors(
|
||||
chat_hugging_face: Any,
|
||||
tools: Dict[str, str],
|
||||
tools: dict[str, str],
|
||||
tool_choice: Any,
|
||||
expected_exception: Any,
|
||||
expected_message: str,
|
||||
|
Reference in New Issue
Block a user