Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

ci: enable Ruff SIM113 (#44102)

Asuka Minatoc99db12d6158
diff --git a/api/.ruff.toml b/api/.ruff.toml
index 1b0837eb1aa..63c2a048fc3 100644
--- a/api/.ruff.toml
+++ b/api/.ruff.toml
@@ -76,7 +76,6 @@ ignore = [
"SIM103", # needless-bool
"SIM105", # suppressible-exception
"SIM108", # if-else-block-instead-of-if-exp
- "SIM113", # enumerate-for-loop
"SIM117", # multiple-with-statements
"TID252", # allow relative imports from parent modules
]
diff --git a/api/commands/plugin.py b/api/commands/plugin.py
index c11f2f1ad84..239d4074b53 100644
--- a/api/commands/plugin.py
+++ b/api/commands/plugin.py
@@ -223,9 +223,7 @@ def transform_datasource_credentials(environment: str):
if notion_package_identifier:
# install notion plugin
PluginService.install_from_marketplace_pkg(tenant_id, [notion_package_identifier])
- auth_count = 0
- for notion_tenant_credential in notion_tenant_credentials:
- auth_count += 1
+ for auth_count, notion_tenant_credential in enumerate(notion_tenant_credentials, start=1):
# get credential oauth params
access_token = notion_tenant_credential.access_token
# notion info
diff --git a/api/core/app/apps/base_app_runner.py b/api/core/app/apps/base_app_runner.py
index d8eac1de7eb..30b7605756b 100644
--- a/api/core/app/apps/base_app_runner.py
+++ b/api/core/app/apps/base_app_runner.py
@@ -188,8 +188,7 @@ class AppRunner:
:return:
"""
if stream:
- index = 0
- for token in text:
+ for index, token in enumerate(text):
chunk = LLMResultChunk(
model=app_generate_entity.model_conf.model,
prompt_messages=prompt_messages,
@@ -197,7 +196,6 @@ class AppRunner:
)
queue_manager.publish(QueueLLMChunkEvent(chunk=chunk), PublishFrom.APPLICATION_MANAGER)
- index += 1
time.sleep(0.01)
queue_manager.publish(
diff --git a/api/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.py b/api/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.py
index 3f2d64e3434..83b400f7eb1 100644
--- a/api/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.py
+++ b/api/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.py
@@ -113,8 +113,7 @@ class DatasetMultiRetrieverTool(DatasetRetrieverBaseTool):
document_context_list.append(sign_segment_content(segment, session=session))
if self.return_resource:
context_list: list[RetrievalSourceMetadata] = []
- resource_number = 1
- for segment in sorted_segments:
+ for resource_number, segment in enumerate(sorted_segments, start=1):
dataset = session.get(Dataset, segment.dataset_id)
document_stmt = select(Document).where(
Document.id == segment.document_id,
@@ -146,7 +145,6 @@ class DatasetMultiRetrieverTool(DatasetRetrieverBaseTool):
else:
source.content = segment.content
context_list.append(source)
- resource_number += 1
for hit_callback in self.hit_callbacks:
hit_callback.return_retriever_resource_info(context_list)