mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-17 23:41:46 +00:00
standard-tests: Add ruff rule UP (pyupgrade) (#31842)
See https://docs.astral.sh/ruff/rules/#pyupgrade-up All auto-fixed
This commit is contained in:
committed by
GitHub
parent
802d2bf249
commit
cd7dce687a
@@ -5,7 +5,7 @@
|
||||
import inspect
|
||||
import os
|
||||
from abc import abstractmethod
|
||||
from typing import Any, Dict, List, Literal, Optional, Tuple, Type
|
||||
from typing import Any, Literal, Optional
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
@@ -78,7 +78,7 @@ class ChatModelTests(BaseStandardTests):
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def chat_model_class(self) -> Type[BaseChatModel]:
|
||||
def chat_model_class(self) -> type[BaseChatModel]:
|
||||
"""The chat model class to test, e.g., ``ChatParrotLink``."""
|
||||
...
|
||||
|
||||
@@ -214,9 +214,9 @@ class ChatModelTests(BaseStandardTests):
|
||||
@property
|
||||
def supported_usage_metadata_details(
|
||||
self,
|
||||
) -> Dict[
|
||||
) -> dict[
|
||||
Literal["invoke", "stream"],
|
||||
List[
|
||||
list[
|
||||
Literal[
|
||||
"audio_input",
|
||||
"audio_output",
|
||||
@@ -804,7 +804,7 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
return params
|
||||
|
||||
@property
|
||||
def init_from_env_params(self) -> Tuple[dict, dict, dict]:
|
||||
def init_from_env_params(self) -> tuple[dict, dict, dict]:
|
||||
"""(tuple) environment variables, additional initialization args, and expected
|
||||
instance attributes for testing initialization from environment variables."""
|
||||
return {}, {}, {}
|
||||
@@ -958,7 +958,7 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
ls_model_type: Literal["chat"]
|
||||
ls_temperature: Optional[float]
|
||||
ls_max_tokens: Optional[int]
|
||||
ls_stop: Optional[List[str]]
|
||||
ls_stop: Optional[list[str]]
|
||||
|
||||
ls_params = model._get_ls_params()
|
||||
try:
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import os
|
||||
from abc import abstractmethod
|
||||
from typing import Tuple, Type
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
@@ -17,7 +16,7 @@ class EmbeddingsTests(BaseStandardTests):
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def embeddings_class(self) -> Type[Embeddings]: ...
|
||||
def embeddings_class(self) -> type[Embeddings]: ...
|
||||
|
||||
@property
|
||||
def embedding_model_params(self) -> dict:
|
||||
@@ -103,7 +102,7 @@ class EmbeddingsUnitTests(EmbeddingsTests):
|
||||
assert model is not None
|
||||
|
||||
@property
|
||||
def init_from_env_params(self) -> Tuple[dict, dict, dict]:
|
||||
def init_from_env_params(self) -> tuple[dict, dict, dict]:
|
||||
"""This property is used in unit tests to test initialization from environment
|
||||
variables. It should return a tuple of three dictionaries that specify the
|
||||
environment variables, additional initialization args, and expected instance
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
from abc import abstractmethod
|
||||
from typing import Tuple, Type, Union
|
||||
from typing import Union
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
@@ -19,7 +19,7 @@ class ToolsTests(BaseStandardTests):
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def tool_constructor(self) -> Union[Type[BaseTool], BaseTool]:
|
||||
def tool_constructor(self) -> Union[type[BaseTool], BaseTool]:
|
||||
"""
|
||||
Returns a class or instance of a tool to be tested.
|
||||
"""
|
||||
@@ -64,7 +64,7 @@ class ToolsUnitTests(ToolsTests):
|
||||
"""
|
||||
|
||||
@property
|
||||
def init_from_env_params(self) -> Tuple[dict, dict, dict]:
|
||||
def init_from_env_params(self) -> tuple[dict, dict, dict]:
|
||||
"""Return env vars, init args, and expected instance attrs for initializing
|
||||
from env vars."""
|
||||
return {}, {}, {}
|
||||
|
Reference in New Issue
Block a user