The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
standard-tests: Add ruff rules PGH (#31869)
Christophe Bornet1276bf3e1d80
diff --git a/libs/standard-tests/langchain_tests/integration_tests/base_store.py b/libs/standard-tests/langchain_tests/integration_tests/base_store.pyindex 446e4eb392..0b04104de3 100644--- a/libs/standard-tests/langchain_tests/integration_tests/base_store.py+++ b/libs/standard-tests/langchain_tests/integration_tests/base_store.py@@ -149,7 +149,7 @@ class BaseStoreSyncTests(BaseStandardTests, Generic[V]):assert sorted(kv_store.yield_keys(prefix="foo")) == ["foo"]-class BaseStoreAsyncTests(BaseStandardTests):+class BaseStoreAsyncTests(BaseStandardTests, Generic[V]):"""Test suite for checking the key-value API of a BaseStore.This test suite verifies the basic key-value API of a BaseStore.diff --git a/libs/standard-tests/langchain_tests/integration_tests/chat_models.py b/libs/standard-tests/langchain_tests/integration_tests/chat_models.pyindex be1703a77b..b9f58010f6 100644--- a/libs/standard-tests/langchain_tests/integration_tests/chat_models.py+++ b/libs/standard-tests/langchain_tests/integration_tests/chat_models.py@@ -1346,7 +1346,7 @@ class ChatModelIntegrationTests(ChatModelTests):# Test streamfull: Optional[BaseMessageChunk] = Nonefor chunk in model_with_tools.stream(query):- full = chunk if full is None else full + chunk # type: ignore+ full = chunk if full is None else full + chunk # type: ignore[assignment]assert isinstance(full, AIMessage)_validate_tool_call_message(full)@@ -1407,7 +1407,7 @@ class ChatModelIntegrationTests(ChatModelTests):# Test astreamfull: Optional[BaseMessageChunk] = Noneasync for chunk in model_with_tools.astream(query):- full = chunk if full is None else full + chunk # type: ignore+ full = chunk if full is None else full + chunk # type: ignore[assignment]assert isinstance(full, AIMessage)_validate_tool_call_message(full)@@ -1743,7 +1743,7 @@ class ChatModelIntegrationTests(ChatModelTests):full: Optional[BaseMessageChunk] = Nonefor chunk in model_with_tools.stream(query):- full = chunk if full is None else full + chunk # type: ignore+ full = chunk if full is None else full + chunk # type: ignore[assignment]assert isinstance(full, AIMessage)_validate_tool_call_message_no_args(full)diff --git a/libs/standard-tests/langchain_tests/integration_tests/indexer.py b/libs/standard-tests/langchain_tests/integration_tests/indexer.pyindex 4f549c4947..9d95ac9ee1 100644--- a/libs/standard-tests/langchain_tests/integration_tests/indexer.py+++ b/libs/standard-tests/langchain_tests/integration_tests/indexer.py@@ -49,7 +49,7 @@ class DocumentIndexerTestSuite(ABC):# Ordering is not guaranteed, need to test carefullydocuments = index.get(ids)- sorted_documents = sorted(documents, key=lambda x: x.id) # type: ignore+ sorted_documents = sorted(documents, key=lambda x: x.id or "")if sorted_documents[0].page_content == "bar":assert sorted_documents[0] == Document(@@ -196,7 +196,7 @@ class DocumentIndexerTestSuite(ABC):}retrieved_documents = index.get(["1", "2", "3", "4"])# The ordering is not guaranteed, so we use a set.- assert sorted(retrieved_documents, key=lambda x: x.id) == [ # type: ignore+ assert sorted(retrieved_documents, key=lambda x: x.id or "") == [Document(page_content="foo", metadata={"id": 1}, id="1"),Document(page_content="bar", metadata={"id": 2}, id="2"),]@@ -239,7 +239,7 @@ class AsyncDocumentIndexTestSuite(ABC):# Ordering is not guaranteed, need to test carefullydocuments = await index.aget(ids)- sorted_documents = sorted(documents, key=lambda x: x.id) # type: ignore+ sorted_documents = sorted(documents, key=lambda x: x.id or "")if sorted_documents[0].page_content == "bar":assert sorted_documents[0] == Document(@@ -388,7 +388,7 @@ class AsyncDocumentIndexTestSuite(ABC):}retrieved_documents = await index.aget(["1", "2", "3", "4"])# The ordering is not guaranteed, so we use a set.- assert sorted(retrieved_documents, key=lambda x: x.id) == [ # type: ignore+ assert sorted(retrieved_documents, key=lambda x: x.id or "") == [Document(page_content="foo", metadata={"id": 1}, id="1"),Document(page_content="bar", metadata={"id": 2}, id="2"),]diff --git a/libs/standard-tests/langchain_tests/unit_tests/chat_models.py b/libs/standard-tests/langchain_tests/unit_tests/chat_models.pyindex 5ba78941e5..24b2cfc271 100644--- a/libs/standard-tests/langchain_tests/unit_tests/chat_models.py+++ b/libs/standard-tests/langchain_tests/unit_tests/chat_models.py@@ -908,7 +908,7 @@ class ChatModelUnitTests(ChatModelTests):# Doing a mypy ignore here since some of the tools are from pydantic# BaseModel 2 which isn't typed properly yet. This will need to be fixed# so type checking does not become annoying to users.- tool_model = model.bind_tools(tools, tool_choice="any") # type: ignore+ tool_model = model.bind_tools(tools, tool_choice="any") # type: ignore[arg-type]assert isinstance(tool_model, RunnableBinding)@pytest.mark.parametrize("schema", TEST_PYDANTIC_MODELS)@@ -962,19 +962,19 @@ class ChatModelUnitTests(ChatModelTests):ls_params = model._get_ls_params()try:- ExpectedParams(**ls_params) # type: ignore+ ExpectedParams(**ls_params) # type: ignore[arg-type]except ValidationErrorV1 as e:pytest.fail(f"Validation error: {e}")# Test optional paramsmodel = self.chat_model_class(- max_tokens=10,- stop=["test"],- **self.chat_model_params, # type: ignore+ max_tokens=10, # type: ignore[call-arg]+ stop=["test"], # type: ignore[call-arg]+ **self.chat_model_params,)ls_params = model._get_ls_params()try:- ExpectedParams(**ls_params) # type: ignore+ ExpectedParams(**ls_params) # type: ignore[arg-type]except ValidationErrorV1 as e:pytest.fail(f"Validation error: {e}")diff --git a/libs/standard-tests/pyproject.toml b/libs/standard-tests/pyproject.tomlindex 566c7a5720..828d484257 100644--- a/libs/standard-tests/pyproject.toml+++ b/libs/standard-tests/pyproject.toml@@ -55,7 +55,7 @@ ignore_missing_imports = truetarget-version = "py39"[tool.ruff.lint]-select = ["E", "F", "I", "T201", "UP",]+select = ["E", "F", "I", "PGH", "T201", "UP",]pyupgrade.keep-runtime-typing = true[tool.coverage.run]diff --git a/libs/standard-tests/tests/unit_tests/test_basic_tool.py b/libs/standard-tests/tests/unit_tests/test_basic_tool.pyindex 2922faad5c..8af2750a9d 100644--- a/libs/standard-tests/tests/unit_tests/test_basic_tool.py+++ b/libs/standard-tests/tests/unit_tests/test_basic_tool.py@@ -6,7 +6,7 @@ from langchain_tests.integration_tests import ToolsIntegrationTestsfrom langchain_tests.unit_tests import ToolsUnitTests-class ParrotMultiplyTool(BaseTool): # type: ignore+class ParrotMultiplyTool(BaseTool):name: str = "ParrotMultiplyTool"description: str = ("Multiply two numbers like a parrot. Parrots always add eighty for their matey."@@ -16,7 +16,7 @@ class ParrotMultiplyTool(BaseTool): # type: ignorereturn a * b + 80-class ParrotMultiplyArtifactTool(BaseTool): # type: ignore+class ParrotMultiplyArtifactTool(BaseTool):name: str = "ParrotMultiplyArtifactTool"description: str = ("Multiply two numbers like a parrot. Parrots always add eighty for their matey."diff --git a/libs/standard-tests/tests/unit_tests/test_in_memory_base_store.py b/libs/standard-tests/tests/unit_tests/test_in_memory_base_store.pyindex d8d635cf42..7349d3ffc5 100644--- a/libs/standard-tests/tests/unit_tests/test_in_memory_base_store.py+++ b/libs/standard-tests/tests/unit_tests/test_in_memory_base_store.py@@ -9,7 +9,7 @@ from langchain_tests.integration_tests.base_store import ()-class TestInMemoryStore(BaseStoreSyncTests):+class TestInMemoryStore(BaseStoreSyncTests[str]):@pytest.fixturedef three_values(self) -> tuple[str, str, str]:return "foo", "bar", "buzz"@@ -19,9 +19,9 @@ class TestInMemoryStore(BaseStoreSyncTests):return InMemoryStore()-class TestInMemoryStoreAsync(BaseStoreAsyncTests):+class TestInMemoryStoreAsync(BaseStoreAsyncTests[str]):@pytest.fixture- def three_values(self) -> tuple[str, str, str]: # type: ignore+ def three_values(self) -> tuple[str, str, str]:return "foo", "bar", "buzz"@pytest.fixture