ci: enable Ruff FURB113 (#44109)

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Asuka Minato
2026-10-15 05:00:19 +00:00
committed by GitHub
co-authored by Codex
parent 7b467ec651
commit 14f863a23f
14 changed files with 206 additions and 210 deletions
-1
View File
@@ -62,7 +62,6 @@ ignore = [
"E712", # true-false-comparison
"F821", # undefined-name
"F841", # unused-variable
"FURB113", # repeated-append
"UP007", # non-pep604-annotation
"B007", # unused-loop-control-variable
"B901", # allow return in yield
+28 -28
View File
@@ -288,21 +288,21 @@ class AgentBackendRunRequestBuilder:
include_shell = run_input.include_shell or run_input.config_layer_config is not None
if include_shell:
layers.append(
RunLayerSpec(
name=DIFY_RUNTIME_LAYER_ID,
config=(DifyRuntimeLayerConfig(backend_binding_ref=run_input.backend_binding_ref)).model_dump(
mode="json"
layers.extend(
[
RunLayerSpec(
name=DIFY_RUNTIME_LAYER_ID,
config=(DifyRuntimeLayerConfig(backend_binding_ref=run_input.backend_binding_ref)).model_dump(
mode="json"
),
),
)
)
# Sandboxed bash workspace (dify.shell). It enters before config so
# eager pulls materialize content in the same filesystem used by model commands.
layers.append(
RunLayerSpec(
name=DIFY_SHELL_LAYER_ID,
config=(run_input.shell_config or DifyShellLayerConfig()).model_dump(mode="json"),
)
# Sandboxed bash workspace (dify.shell). It enters before config so
# eager pulls materialize content in the same filesystem used by model commands.
RunLayerSpec(
name=DIFY_SHELL_LAYER_ID,
config=(run_input.shell_config or DifyShellLayerConfig()).model_dump(mode="json"),
),
]
)
if run_input.config_layer_config is not None:
@@ -422,21 +422,21 @@ class AgentBackendRunRequestBuilder:
include_shell = run_input.include_shell or run_input.config_layer_config is not None
if include_shell:
layers.append(
RunLayerSpec(
name=DIFY_RUNTIME_LAYER_ID,
config=(DifyRuntimeLayerConfig(backend_binding_ref=run_input.backend_binding_ref)).model_dump(
mode="json"
layers.extend(
[
RunLayerSpec(
name=DIFY_RUNTIME_LAYER_ID,
config=(DifyRuntimeLayerConfig(backend_binding_ref=run_input.backend_binding_ref)).model_dump(
mode="json"
),
),
)
)
# Sandboxed bash workspace (dify.shell). It enters before config so
# eager pulls materialize content in the same filesystem used by model commands.
layers.append(
RunLayerSpec(
name=DIFY_SHELL_LAYER_ID,
config=(run_input.shell_config or DifyShellLayerConfig()).model_dump(mode="json"),
)
# Sandboxed bash workspace (dify.shell). It enters before config so
# eager pulls materialize content in the same filesystem used by model commands.
RunLayerSpec(
name=DIFY_SHELL_LAYER_ID,
config=(run_input.shell_config or DifyShellLayerConfig()).model_dump(mode="json"),
),
]
)
if run_input.config_layer_config is not None:
+16 -11
View File
@@ -114,20 +114,25 @@ def build_oauth_authorization_server_metadata_discovery_urls(auth_server_url: st
base = f"{parsed.scheme}://{parsed.netloc}"
path = parsed.path.rstrip("/")
# OAuth 2.0 Authorization Server Metadata at root (MCP-03-26)
urls.append(f"{base}/.well-known/oauth-authorization-server")
# OpenID Connect Discovery at root
urls.append(f"{base}/.well-known/openid-configuration")
urls.extend(
[
f"{base}/.well-known/oauth-authorization-server",
# OpenID Connect Discovery at root
f"{base}/.well-known/openid-configuration",
]
)
if path:
# OpenID Connect Discovery with path insertion
urls.append(f"{base}/.well-known/openid-configuration{path}")
# OpenID Connect Discovery path appending
urls.append(f"{base}{path}/.well-known/openid-configuration")
# OAuth 2.0 Authorization Server Metadata with path insertion
urls.append(f"{base}/.well-known/oauth-authorization-server{path}")
urls.extend(
[
f"{base}/.well-known/openid-configuration{path}",
# OpenID Connect Discovery path appending
f"{base}{path}/.well-known/openid-configuration",
# OAuth 2.0 Authorization Server Metadata with path insertion
f"{base}/.well-known/oauth-authorization-server{path}",
]
)
return urls
+1 -2
View File
@@ -201,8 +201,7 @@ class WordExtractor(BaseExtractor):
header_row = table.rows[0]
headers = self._parse_row(header_row, image_map, total_cols)
markdown.append("| " + " | ".join(headers) + " |")
markdown.append("| " + " | ".join(["---"] * total_cols) + " |")
markdown.extend(("| " + " | ".join(headers) + " |", "| " + " | ".join(["---"] * total_cols) + " |"))
for row in table.rows[1:]:
row_cells = self._parse_row(row, image_map, total_cols)
@@ -361,8 +361,7 @@ class WorkflowAgentRuntimeRequestBuilder:
lines.append(f"- User query: {query}")
if uploaded_files is not None:
lines.append("- Uploaded workflow files:")
lines.append(f" - sys.files: {uploaded_files}")
lines.extend(("- Uploaded workflow files:", f" - sys.files: {uploaded_files}"))
if resolved_outputs:
lines.append("- Previous node outputs:")
+1 -2
View File
@@ -257,8 +257,7 @@ def init_app(app: DifyApp) -> Celery:
"schedule": timedelta(minutes=dify_config.HUMAN_INPUT_TIMEOUT_TASK_INTERVAL),
}
if dify_config.ENABLE_CHECK_UPGRADABLE_PLUGIN_TASK and dify_config.MARKETPLACE_ENABLED:
imports.append("schedule.check_upgradable_plugin_task")
imports.append("tasks.process_tenant_plugin_autoupgrade_check_task")
imports.extend(("schedule.check_upgradable_plugin_task", "tasks.process_tenant_plugin_autoupgrade_check_task"))
beat_schedule["check_upgradable_plugin_task"] = {
"task": "schedule.check_upgradable_plugin_task.check_upgradable_plugin_task",
"schedule": crontab(minute="*/15"),
+8 -34
View File
@@ -255,40 +255,14 @@ class Dataset(Base):
for dataset_metadata in dataset_metadatas
]
if self.built_in_field_enabled:
doc_metadata.append(
{
"id": "built-in",
"name": BuiltInField.document_name,
"type": "string",
}
)
doc_metadata.append(
{
"id": "built-in",
"name": BuiltInField.uploader,
"type": "string",
}
)
doc_metadata.append(
{
"id": "built-in",
"name": BuiltInField.upload_date,
"type": "time",
}
)
doc_metadata.append(
{
"id": "built-in",
"name": BuiltInField.last_update_date,
"type": "time",
}
)
doc_metadata.append(
{
"id": "built-in",
"name": BuiltInField.source,
"type": "string",
}
doc_metadata.extend(
(
{"id": "built-in", "name": BuiltInField.document_name, "type": "string"},
{"id": "built-in", "name": BuiltInField.uploader, "type": "string"},
{"id": "built-in", "name": BuiltInField.upload_date, "type": "time"},
{"id": "built-in", "name": BuiltInField.last_update_date, "type": "time"},
{"id": "built-in", "name": BuiltInField.source, "type": "string"},
)
)
return doc_metadata
@@ -273,43 +273,44 @@ class BaiduVector(BaseVector):
# Construct field schema
fields = []
fields.append(
Field(
VDBField.PRIMARY_KEY,
FieldType.STRING,
primary_key=True,
partition_key=True,
auto_increment=False,
not_null=True,
fields.extend(
(
Field(
VDBField.PRIMARY_KEY,
FieldType.STRING,
primary_key=True,
partition_key=True,
auto_increment=False,
not_null=True,
),
Field(VDBField.CONTENT_KEY, FieldType.TEXT, not_null=False),
Field(VDBField.METADATA_KEY, FieldType.JSON, not_null=False),
Field(VDBField.VECTOR, FieldType.FLOAT_VECTOR, not_null=True, dimension=dimension),
)
)
fields.append(Field(VDBField.CONTENT_KEY, FieldType.TEXT, not_null=False))
fields.append(Field(VDBField.METADATA_KEY, FieldType.JSON, not_null=False))
fields.append(Field(VDBField.VECTOR, FieldType.FLOAT_VECTOR, not_null=True, dimension=dimension))
# Construct vector index params
indexes = []
indexes.append(
VectorIndex(
index_name=self.vector_index,
index_type=index_type,
field=VDBField.VECTOR,
metric_type=metric_type,
params=HNSWParams(m=16, efconstruction=200),
auto_build=True,
auto_build_index_policy=AutoBuildRowCountIncrement(
row_count_increment=self._client_config.auto_build_row_count_increment,
row_count_increment_ratio=self._client_config.auto_build_row_count_increment_ratio,
indexes.extend(
[
VectorIndex(
index_name=self.vector_index,
index_type=index_type,
field=VDBField.VECTOR,
metric_type=metric_type,
params=HNSWParams(m=16, efconstruction=200),
auto_build=True,
auto_build_index_policy=AutoBuildRowCountIncrement(
row_count_increment=self._client_config.auto_build_row_count_increment,
row_count_increment_ratio=self._client_config.auto_build_row_count_increment_ratio,
),
),
)
)
# Filtering index
indexes.append(
FilteringIndex(
index_name=self.filtering_index,
fields=[VDBField.METADATA_KEY],
)
# Filtering index
FilteringIndex(
index_name=self.filtering_index,
fields=[VDBField.METADATA_KEY],
),
]
)
# Get analyzer and parse_mode from config
@@ -146,8 +146,7 @@ class LindormVectorStore(BaseVector):
action_header["index"]["routing"] = self._routing
action_values[ROUTING_FIELD] = self._routing
actions.append(action_header)
actions.append(action_values)
actions.extend((action_header, action_values))
try:
_bulk_with_retry(actions)
@@ -354,12 +354,15 @@ class MilvusVector(BaseVector):
):
content_field_kwargs["analyzer_params"] = self._client_config.analyzer_params
fields.append(FieldSchema(Field.CONTENT_KEY, DataType.VARCHAR, **content_field_kwargs))
# Create the primary key field
fields.append(FieldSchema(Field.PRIMARY_KEY, DataType.INT64, is_primary=True, auto_id=True))
# Create the vector field, supports binary or float vectors
fields.append(FieldSchema(Field.VECTOR, infer_dtype_bydata(embeddings[0]), dim=dim))
fields.extend(
[
FieldSchema(Field.CONTENT_KEY, DataType.VARCHAR, **content_field_kwargs),
# Create the primary key field
FieldSchema(Field.PRIMARY_KEY, DataType.INT64, is_primary=True, auto_id=True),
# Create the vector field, supports binary or float vectors
FieldSchema(Field.VECTOR, infer_dtype_bydata(embeddings[0]), dim=dim),
]
)
# Create Sparse Vector Index for the collection
if self._hybrid_search_enabled:
fields.append(FieldSchema(Field.SPARSE_VECTOR, DataType.SPARSE_FLOAT_VECTOR))
+23 -27
View File
@@ -252,33 +252,29 @@ def get_document_built_in_fields(document: Document, *, session: Session) -> lis
def format_document_built_in_fields(document: Document, *, uploader_name: str | None) -> list[DocMetadataDetailItem]:
built_in_fields: list[DocMetadataDetailItem] = []
built_in_fields.append(
{"id": "built-in", "name": BuiltInField.document_name, "type": "string", "value": document.name}
)
built_in_fields.append({"id": "built-in", "name": BuiltInField.uploader, "type": "string", "value": uploader_name})
built_in_fields.append(
{
"id": "built-in",
"name": BuiltInField.upload_date,
"type": "time",
"value": str(document.created_at.timestamp()),
}
)
built_in_fields.append(
{
"id": "built-in",
"name": BuiltInField.last_update_date,
"type": "time",
"value": str(document.updated_at.timestamp()),
}
)
built_in_fields.append(
{
"id": "built-in",
"name": BuiltInField.source,
"type": "string",
"value": MetadataDataSource[document.data_source_type],
}
built_in_fields.extend(
(
{"id": "built-in", "name": BuiltInField.document_name, "type": "string", "value": document.name},
{"id": "built-in", "name": BuiltInField.uploader, "type": "string", "value": uploader_name},
{
"id": "built-in",
"name": BuiltInField.upload_date,
"type": "time",
"value": str(document.created_at.timestamp()),
},
{
"id": "built-in",
"name": BuiltInField.last_update_date,
"type": "time",
"value": str(document.updated_at.timestamp()),
},
{
"id": "built-in",
"name": BuiltInField.source,
"type": "string",
"value": MetadataDataSource[document.data_source_type],
},
)
)
return built_in_fields
@@ -560,16 +560,20 @@ class TestFileUploads:
# Build multipart body
body_parts = []
body_parts.append(f"------{boundary}".encode())
body_parts.append(b'Content-Disposition: form-data; name="image"; filename="test.png"')
body_parts.append(b"Content-Type: image/png")
body_parts.append(b"")
body_parts.append(binary_content)
body_parts.append(f"------{boundary}".encode())
body_parts.append(b'Content-Disposition: form-data; name="caption"')
body_parts.append(b"")
body_parts.append(b"Test image")
body_parts.append(f"------{boundary}--".encode())
body_parts.extend(
(
f"------{boundary}".encode(),
b'Content-Disposition: form-data; name="image"; filename="test.png"',
b"Content-Type: image/png",
b"",
binary_content,
f"------{boundary}".encode(),
b'Content-Disposition: form-data; name="caption"',
b"",
b"Test image",
f"------{boundary}--".encode(),
)
)
body = b"\r\n".join(body_parts)
@@ -602,16 +606,20 @@ class TestFileUploads:
binary_content = b"\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00"
body_parts = []
body_parts.append(f"------{boundary}".encode())
body_parts.append(b'Content-Disposition: form-data; name="photo"; filename="photo.jpg"')
body_parts.append(b"Content-Type: image/jpeg")
body_parts.append(b"")
body_parts.append(binary_content)
body_parts.append(f"------{boundary}".encode())
body_parts.append(b'Content-Disposition: form-data; name="album"')
body_parts.append(b"")
body_parts.append(b"Vacation 2024")
body_parts.append(f"------{boundary}--".encode())
body_parts.extend(
(
f"------{boundary}".encode(),
b'Content-Disposition: form-data; name="photo"; filename="photo.jpg"',
b"Content-Type: image/jpeg",
b"",
binary_content,
f"------{boundary}".encode(),
b'Content-Disposition: form-data; name="album"',
b"",
b"Vacation 2024",
f"------{boundary}--".encode(),
)
)
body = b"\r\n".join(body_parts)
@@ -648,23 +656,27 @@ class TestFileUploads:
body_parts = []
# First file (text)
body_parts.append(f"------{boundary}".encode())
body_parts.append(b'Content-Disposition: form-data; name="files"; filename="doc.txt"')
body_parts.append(b"Content-Type: text/plain")
body_parts.append(b"")
body_parts.append(text_file)
# Second file (binary)
body_parts.append(f"------{boundary}".encode())
body_parts.append(b'Content-Disposition: form-data; name="files"; filename="data.bin"')
body_parts.append(b"Content-Type: application/octet-stream")
body_parts.append(b"")
body_parts.append(binary_file)
# Additional form field
body_parts.append(f"------{boundary}".encode())
body_parts.append(b'Content-Disposition: form-data; name="folder"')
body_parts.append(b"")
body_parts.append(b"uploads/2024")
body_parts.append(f"------{boundary}--".encode())
body_parts.extend(
[
f"------{boundary}".encode(),
b'Content-Disposition: form-data; name="files"; filename="doc.txt"',
b"Content-Type: text/plain",
b"",
text_file,
# Second file (binary)
f"------{boundary}".encode(),
b'Content-Disposition: form-data; name="files"; filename="data.bin"',
b"Content-Type: application/octet-stream",
b"",
binary_file,
# Additional form field
f"------{boundary}".encode(),
b'Content-Disposition: form-data; name="folder"',
b"",
b"uploads/2024",
f"------{boundary}--".encode(),
]
)
body = b"\r\n".join(body_parts)
@@ -700,16 +712,20 @@ class TestFileUploads:
file_content = b"This is my file content with special chars: \xf0\x9f\x98\x80"
body_parts = []
body_parts.append(f"------{boundary}".encode())
body_parts.append(b'Content-Disposition: form-data; name="upload"; filename="emoji.txt"')
body_parts.append(b"Content-Type: text/plain; charset=utf-8")
body_parts.append(b"")
body_parts.append(file_content)
body_parts.append(f"------{boundary}".encode())
body_parts.append(b'Content-Disposition: form-data; name="metadata"')
body_parts.append(b"")
body_parts.append(b'{"encoding": "utf-8", "size": 42}')
body_parts.append(f"------{boundary}--".encode())
body_parts.extend(
(
f"------{boundary}".encode(),
b'Content-Disposition: form-data; name="upload"; filename="emoji.txt"',
b"Content-Type: text/plain; charset=utf-8",
b"",
file_content,
f"------{boundary}".encode(),
b'Content-Disposition: form-data; name="metadata"',
b"",
b'{"encoding": "utf-8", "size": 42}',
f"------{boundary}--".encode(),
)
)
body = b"\r\n".join(body_parts)
@@ -624,19 +624,22 @@ class TableTestRunner:
Formatted report string
"""
report = []
report.append("=" * 80)
report.append("TEST SUITE REPORT")
report.append("=" * 80)
report.append("")
# Summary
report.append("SUMMARY:")
report.append(f" Total Tests: {suite_result.total_tests}")
report.append(f" Passed: {suite_result.passed_tests}")
report.append(f" Failed: {suite_result.failed_tests}")
report.append(f" Success Rate: {suite_result.success_rate:.1f}%")
report.append(f" Total Time: {suite_result.total_execution_time:.2f}s")
report.append("")
report.extend(
[
"=" * 80,
"TEST SUITE REPORT",
"=" * 80,
"",
# Summary
"SUMMARY:",
f" Total Tests: {suite_result.total_tests}",
f" Passed: {suite_result.passed_tests}",
f" Failed: {suite_result.failed_tests}",
f" Success Rate: {suite_result.success_rate:.1f}%",
f" Total Time: {suite_result.total_execution_time:.2f}s",
"",
]
)
# Failed tests details
failed_results = suite_result.get_failed_results()
@@ -466,10 +466,13 @@ class TestFormatVariableReferenceErrors:
for index in range(11):
producer_id = f"p{index:02d}"
consumer_id = f"c{index:02d}"
nodes.append(_node(producer_id, "tool", f"Producer {index:02d}"))
nodes.append(_node(consumer_id, "llm", f"Consumer {index:02d}", selector=[producer_id, "text"]))
edges.append(_edge("router", producer_id, "true"))
edges.append(_edge("router", consumer_id, "false"))
nodes.extend(
(
_node(producer_id, "tool", f"Producer {index:02d}"),
_node(consumer_id, "llm", f"Consumer {index:02d}", selector=[producer_id, "text"]),
)
)
edges.extend((_edge("router", producer_id, "true"), _edge("router", consumer_id, "false")))
issues = validate_variable_references({"nodes": nodes, "edges": edges})
assert len(issues) == 11
message = format_variable_reference_errors(issues)