The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
chore(langchain): add ruff rule ERA (#32867)
Christophe Bornet699a5d06d159
diff --git a/libs/langchain/langchain/_api/module_import.py b/libs/langchain/langchain/_api/module_import.pyindex d96f70c0bf..4b7793fd8b 100644--- a/libs/langchain/langchain/_api/module_import.py+++ b/libs/langchain/langchain/_api/module_import.py@@ -85,10 +85,10 @@ def create_importer(and deprecated_lookupsand name in deprecated_lookups# Depth 3:- # internal.py- # module_import.py- # Module in langchain that uses this function- # [calling code] whose frame we want to inspect.+ # -> internal.py+ # |-> module_import.py+ # |-> Module in langchain that uses this function+ # |-> [calling code] whose frame we want to inspect.and not internal.is_caller_internal(depth=3)):warn_deprecated(@@ -120,9 +120,9 @@ def create_importer(not is_interactive_env()# Depth 3:# internal.py- # module_import.py- # Module in langchain that uses this function- # [calling code] whose frame we want to inspect.+ # |-> module_import.py+ # |->Module in langchain that uses this function+ # |-> [calling code] whose frame we want to inspect.and not internal.is_caller_internal(depth=3)):warn_deprecated(diff --git a/libs/langchain/pyproject.toml b/libs/langchain/pyproject.tomlindex 0db0925bd6..e50cb40557 100644--- a/libs/langchain/pyproject.toml+++ b/libs/langchain/pyproject.toml@@ -160,11 +160,10 @@ ignore = ["TD003", # Missing issue link in TODO# TODO rules- "ANN401",- "BLE",+ "ANN401", # No type Any+ "BLE", # Blind exceptions"D100", # pydocstyle: missing docstring in public module"D104", # pydocstyle: missing docstring in public package- "ERA","PLC0415", # pylint: import-outside-top-level"TRY301", # tryceratops: raise-within-try]diff --git a/libs/langchain/tests/unit_tests/evaluation/scoring/test_eval_chain.py b/libs/langchain/tests/unit_tests/evaluation/scoring/test_eval_chain.pyindex 67fd54d586..b216cd4d98 100644--- a/libs/langchain/tests/unit_tests/evaluation/scoring/test_eval_chain.py+++ b/libs/langchain/tests/unit_tests/evaluation/scoring/test_eval_chain.py@@ -33,7 +33,7 @@ Rating: 10"""text = """This answer is really good.Rating: [[0]]"""- # Not in range [1, 10]+ # Rating is not in range [1, 10]with pytest.raises(ValueError, match="with the verdict between 1 and 10"):output_parser.parse(text)diff --git a/libs/langchain/tests/unit_tests/memory/test_combined_memory.py b/libs/langchain/tests/unit_tests/memory/test_combined_memory.pyindex 085a8eabdc..c9ea7a9b15 100644--- a/libs/langchain/tests/unit_tests/memory/test_combined_memory.py+++ b/libs/langchain/tests/unit_tests/memory/test_combined_memory.py@@ -1,7 +1,5 @@"""Test for CombinedMemory class."""-# from langchain_core.prompts import PromptTemplate-import pytestfrom langchain.memory import CombinedMemory, ConversationBufferMemorydiff --git a/libs/langchain/tests/unit_tests/retrievers/test_multi_vector.py b/libs/langchain/tests/unit_tests/retrievers/test_multi_vector.pyindex 3947d9eff2..fd49ebadc7 100644--- a/libs/langchain/tests/unit_tests/retrievers/test_multi_vector.py+++ b/libs/langchain/tests/unit_tests/retrievers/test_multi_vector.py@@ -76,7 +76,7 @@ def test_multi_vector_retriever_similarity_search_with_score() -> None:vectorstore = InMemoryVectorstoreWithSearch()vectorstore.add_documents(documents, ids=["1"])- # score_threshold = 0.5+ # test with score_threshold = 0.5retriever = MultiVectorRetriever(vectorstore=vectorstore,docstore=InMemoryStore(),@@ -89,7 +89,7 @@ def test_multi_vector_retriever_similarity_search_with_score() -> None:assert len(results) == 1assert results[0].page_content == "test document"- # score_threshold = 0.9+ # test with score_threshold = 0.9retriever = MultiVectorRetriever(vectorstore=vectorstore,docstore=InMemoryStore(),@@ -107,7 +107,7 @@ async def test_multi_vector_retriever_similarity_search_with_score_async() -> Novectorstore = InMemoryVectorstoreWithSearch()await vectorstore.aadd_documents(documents, ids=["1"])- # score_threshold = 0.5+ # test with score_threshold = 0.5retriever = MultiVectorRetriever(vectorstore=vectorstore,docstore=InMemoryStore(),@@ -120,7 +120,7 @@ async def test_multi_vector_retriever_similarity_search_with_score_async() -> Noassert len(results) == 1assert results[0].page_content == "test document"- # score_threshold = 0.9+ # test with score_threshold = 0.9retriever = MultiVectorRetriever(vectorstore=vectorstore,docstore=InMemoryStore(),