Skip to content

Commit ba144c9

Browse files
cbornetmdrxy
andauthored
langchain: Add ruff rule RUF (#31874)
All auto-fixes See https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf --------- Co-authored-by: Mason Daugherty <[email protected]>
1 parent ed35372 commit ba144c9

File tree

291 files changed

+777
-786
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+777
-786
lines changed

libs/langchain/langchain/__init__.py

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# ruff: noqa: E402
21
"""Main entrypoint into package."""
32

43
import warnings
@@ -391,50 +390,50 @@ def __getattr__(name: str) -> Any:
391390

392391

393392
__all__ = [
394-
"LLMChain",
395-
"LLMCheckerChain",
396-
"LLMMathChain",
397-
"ArxivAPIWrapper",
398-
"GoldenQueryAPIWrapper",
399-
"SelfAskWithSearchChain",
400-
"SerpAPIWrapper",
401-
"SerpAPIChain",
402-
"SearxSearchWrapper",
403-
"GoogleSearchAPIWrapper",
404-
"GoogleSerperAPIWrapper",
405-
"WolframAlphaAPIWrapper",
406-
"WikipediaAPIWrapper",
393+
"FAISS",
407394
"Anthropic",
395+
"ArxivAPIWrapper",
408396
"Banana",
397+
"BasePromptTemplate",
409398
"CerebriumAI",
410399
"Cohere",
400+
"ConversationChain",
401+
"ElasticVectorSearch",
402+
"FewShotPromptTemplate",
411403
"ForefrontAI",
404+
"GoldenQueryAPIWrapper",
405+
"GoogleSearchAPIWrapper",
406+
"GoogleSerperAPIWrapper",
412407
"GooseAI",
408+
"HuggingFaceHub",
409+
"HuggingFacePipeline",
410+
"HuggingFaceTextGenInference",
411+
"InMemoryDocstore",
412+
"LLMChain",
413+
"LLMCheckerChain",
414+
"LLMMathChain",
415+
"LlamaCpp",
416+
"MRKLChain",
413417
"Modal",
414418
"OpenAI",
415419
"Petals",
416420
"PipelineAI",
417-
"StochasticAI",
418-
"Writer",
419-
"BasePromptTemplate",
421+
"PowerBIDataset",
420422
"Prompt",
421-
"FewShotPromptTemplate",
422423
"PromptTemplate",
424+
"QAWithSourcesChain",
423425
"ReActChain",
424-
"Wikipedia",
425-
"HuggingFaceHub",
426-
"SagemakerEndpoint",
427-
"HuggingFacePipeline",
428426
"SQLDatabase",
429-
"PowerBIDataset",
430-
"FAISS",
431-
"MRKLChain",
427+
"SagemakerEndpoint",
428+
"SearxSearchWrapper",
429+
"SelfAskWithSearchChain",
430+
"SerpAPIChain",
431+
"SerpAPIWrapper",
432+
"StochasticAI",
432433
"VectorDBQA",
433-
"ElasticVectorSearch",
434-
"InMemoryDocstore",
435-
"ConversationChain",
436434
"VectorDBQAWithSourcesChain",
437-
"QAWithSourcesChain",
438-
"LlamaCpp",
439-
"HuggingFaceTextGenInference",
435+
"Wikipedia",
436+
"WikipediaAPIWrapper",
437+
"WolframAlphaAPIWrapper",
438+
"Writer",
440439
]

libs/langchain/langchain/_api/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
from .module_import import create_importer
2020

2121
__all__ = [
22-
"deprecated",
2322
"LangChainDeprecationWarning",
23+
"create_importer",
24+
"deprecated",
2425
"suppress_langchain_deprecation_warning",
2526
"surface_langchain_deprecation_warnings",
2627
"warn_deprecated",
27-
"create_importer",
2828
]

libs/langchain/langchain/_api/deprecation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"details, refer to the "
1616
"`LangGraph documentation <https://langchain-ai.github.io/langgraph/>`_"
1717
" as well as guides for "
18-
"`Migrating from AgentExecutor <https://python.langchain.com/docs/how_to/migrate_agent/>`_" # noqa: E501
18+
"`Migrating from AgentExecutor <https://python.langchain.com/docs/how_to/migrate_agent/>`_"
1919
" and LangGraph's "
20-
"`Pre-built ReAct agent <https://langchain-ai.github.io/langgraph/how-tos/create-react-agent/>`_." # noqa: E501
20+
"`Pre-built ReAct agent <https://langchain-ai.github.io/langgraph/how-tos/create-react-agent/>`_."
2121
)
2222

2323

@@ -27,6 +27,6 @@
2727
"LangChainPendingDeprecationWarning",
2828
"deprecated",
2929
"suppress_langchain_deprecation_warning",
30-
"warn_deprecated",
3130
"surface_langchain_deprecation_warnings",
31+
"warn_deprecated",
3232
]

libs/langchain/langchain/_api/path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from langchain_core._api.path import as_import_path, get_relative_path
22

3-
__all__ = ["get_relative_path", "as_import_path"]
3+
__all__ = ["as_import_path", "get_relative_path"]

libs/langchain/langchain/adapters/openai.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ def __getattr__(name: str) -> Any:
4747

4848

4949
__all__ = [
50-
"IndexableBaseModel",
51-
"Choice",
50+
"Chat",
51+
"ChatCompletion",
52+
"ChatCompletionChunk",
5253
"ChatCompletions",
54+
"Choice",
5355
"ChoiceChunk",
54-
"ChatCompletionChunk",
56+
"Completions",
57+
"IndexableBaseModel",
58+
"chat",
5559
"convert_dict_to_message",
5660
"convert_message_to_dict",
57-
"convert_openai_messages",
58-
"ChatCompletion",
5961
"convert_messages_for_finetuning",
60-
"Completions",
61-
"Chat",
62-
"chat",
62+
"convert_openai_messages",
6363
]

libs/langchain/langchain/agents/__init__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,29 +154,29 @@ def __getattr__(name: str) -> Any:
154154
"ReActTextWorldAgent",
155155
"SelfAskWithSearchChain",
156156
"StructuredChatAgent",
157+
"Tool",
158+
"XMLAgent",
157159
"ZeroShotAgent",
158160
"create_json_agent",
161+
"create_json_chat_agent",
162+
"create_openai_functions_agent",
163+
"create_openai_tools_agent",
159164
"create_openapi_agent",
160165
"create_pbi_agent",
161166
"create_pbi_chat_agent",
167+
"create_react_agent",
168+
"create_self_ask_with_search_agent",
162169
"create_spark_sql_agent",
163170
"create_sql_agent",
171+
"create_structured_chat_agent",
172+
"create_tool_calling_agent",
164173
"create_vectorstore_agent",
165174
"create_vectorstore_router_agent",
175+
"create_xml_agent",
166176
"get_all_tool_names",
167177
"initialize_agent",
168178
"load_agent",
169179
"load_huggingface_tool",
170180
"load_tools",
171-
"XMLAgent",
172-
"create_openai_functions_agent",
173-
"create_xml_agent",
174-
"create_react_agent",
175-
"create_openai_tools_agent",
176-
"create_self_ask_with_search_agent",
177-
"create_json_chat_agent",
178-
"create_structured_chat_agent",
179-
"create_tool_calling_agent",
180-
"Tool",
181181
"tool",
182182
]

libs/langchain/langchain/agents/agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ def output_keys(self) -> list[str]:
12411241
:meta private:
12421242
"""
12431243
if self.return_intermediate_steps:
1244-
return self._action_agent.return_values + ["intermediate_steps"]
1244+
return [*self._action_agent.return_values, "intermediate_steps"]
12451245
return self._action_agent.return_values
12461246

12471247
def lookup_tool(self, name: str) -> BaseTool:
@@ -1349,7 +1349,7 @@ def _iter_next_step(
13491349
"An output parsing error occurred. "
13501350
"In order to pass this error back to the agent and have it try "
13511351
"again, pass `handle_parsing_errors=True` to the AgentExecutor. "
1352-
f"This is the error: {str(e)}"
1352+
f"This is the error: {e!s}"
13531353
)
13541354
raise ValueError(msg)
13551355
text = str(e)
@@ -1485,7 +1485,7 @@ async def _aiter_next_step(
14851485
"An output parsing error occurred. "
14861486
"In order to pass this error back to the agent and have it try "
14871487
"again, pass `handle_parsing_errors=True` to the AgentExecutor. "
1488-
f"This is the error: {str(e)}"
1488+
f"This is the error: {e!s}"
14891489
)
14901490
raise ValueError(msg)
14911491
text = str(e)

libs/langchain/langchain/agents/agent_toolkits/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,28 +140,28 @@ def __getattr__(name: str) -> Any:
140140
"JiraToolkit",
141141
"JsonToolkit",
142142
"MultionToolkit",
143-
"NasaToolkit",
144143
"NLAToolkit",
144+
"NasaToolkit",
145145
"O365Toolkit",
146146
"OpenAPIToolkit",
147147
"PlayWrightBrowserToolkit",
148148
"PowerBIToolkit",
149-
"SlackToolkit",
150-
"SteamToolkit",
151149
"SQLDatabaseToolkit",
150+
"SlackToolkit",
152151
"SparkSQLToolkit",
152+
"SteamToolkit",
153153
"VectorStoreInfo",
154154
"VectorStoreRouterToolkit",
155155
"VectorStoreToolkit",
156156
"ZapierToolkit",
157+
"create_conversational_retrieval_agent",
157158
"create_json_agent",
158159
"create_openapi_agent",
159160
"create_pbi_agent",
160161
"create_pbi_chat_agent",
162+
"create_retriever_tool",
161163
"create_spark_sql_agent",
162164
"create_sql_agent",
163165
"create_vectorstore_agent",
164166
"create_vectorstore_router_agent",
165-
"create_conversational_retrieval_agent",
166-
"create_retriever_tool",
167167
]

libs/langchain/langchain/agents/agent_toolkits/github/toolkit.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ def __getattr__(name: str) -> Any:
5151

5252

5353
__all__ = [
54-
"NoInput",
55-
"GetIssue",
54+
"BranchName",
5655
"CommentOnIssue",
57-
"GetPR",
58-
"CreatePR",
5956
"CreateFile",
60-
"ReadFile",
61-
"UpdateFile",
57+
"CreatePR",
58+
"CreateReviewRequest",
6259
"DeleteFile",
6360
"DirectoryPath",
64-
"BranchName",
61+
"GetIssue",
62+
"GetPR",
63+
"GitHubToolkit",
64+
"NoInput",
65+
"ReadFile",
6566
"SearchCode",
66-
"CreateReviewRequest",
6767
"SearchIssuesAndPRs",
68-
"GitHubToolkit",
68+
"UpdateFile",
6969
]

libs/langchain/langchain/agents/agent_toolkits/openapi/planner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ def __getattr__(name: str) -> Any:
4343

4444

4545
__all__ = [
46+
"RequestsDeleteToolWithParsing",
4647
"RequestsGetToolWithParsing",
47-
"RequestsPostToolWithParsing",
4848
"RequestsPatchToolWithParsing",
49+
"RequestsPostToolWithParsing",
4950
"RequestsPutToolWithParsing",
50-
"RequestsDeleteToolWithParsing",
5151
"create_openapi_agent",
5252
]

0 commit comments

Comments
 (0)