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.

fix: remove ruff ignore SIM300 (#11810)

barabicud0570675436e
diff --git a/api/.ruff.toml b/api/.ruff.toml
index 0f3185223c1..26a1b977a9f 100644
--- a/api/.ruff.toml
+++ b/api/.ruff.toml
@@ -70,7 +70,6 @@ ignore = [
"SIM113", # eumerate-for-loop
"SIM117", # multiple-with-statements
"SIM210", # if-expr-with-true-false
- "SIM300", # yoda-conditions,
]
[lint.per-file-ignores]
diff --git a/api/controllers/console/admin.py b/api/controllers/console/admin.py
index a70c4a31c7d..8c0bf8710d3 100644
--- a/api/controllers/console/admin.py
+++ b/api/controllers/console/admin.py
@@ -31,7 +31,7 @@ def admin_required(view):
if auth_scheme != "bearer":
raise Unauthorized("Invalid Authorization header format. Expected 'Bearer <api-key>' format.")
- if dify_config.ADMIN_API_KEY != auth_token:
+ if auth_token != dify_config.ADMIN_API_KEY:
raise Unauthorized("API key is invalid.")
return view(*args, **kwargs)
diff --git a/api/core/model_runtime/model_providers/replicate/text_embedding/text_embedding.py b/api/core/model_runtime/model_providers/replicate/text_embedding/text_embedding.py
index c4e9d0b9c6c..41759fe07d0 100644
--- a/api/core/model_runtime/model_providers/replicate/text_embedding/text_embedding.py
+++ b/api/core/model_runtime/model_providers/replicate/text_embedding/text_embedding.py
@@ -119,7 +119,7 @@ class ReplicateEmbeddingModel(_CommonReplicate, TextEmbeddingModel):
embeddings.append(result[0].get("embedding"))
return [list(map(float, e)) for e in embeddings]
- elif "texts" == text_input_key:
+ elif text_input_key == "texts":
result = client.run(
replicate_model_version,
input={
diff --git a/api/tests/integration_tests/model_runtime/__mock/xinference.py b/api/tests/integration_tests/model_runtime/__mock/xinference.py
index 5f7dad50c10..794f4b05856 100644
--- a/api/tests/integration_tests/model_runtime/__mock/xinference.py
+++ b/api/tests/integration_tests/model_runtime/__mock/xinference.py
@@ -21,13 +21,13 @@ class MockXinferenceClass:
if not re.match(r"https?:\/\/[^\s\/$.?#].[^\s]*$", self.base_url):
raise RuntimeError("404 Not Found")
- if "generate" == model_uid:
+ if model_uid == "generate":
return RESTfulGenerateModelHandle(model_uid, base_url=self.base_url, auth_headers={})
- if "chat" == model_uid:
+ if model_uid == "chat":
return RESTfulChatModelHandle(model_uid, base_url=self.base_url, auth_headers={})
- if "embedding" == model_uid:
+ if model_uid == "embedding":
return RESTfulEmbeddingModelHandle(model_uid, base_url=self.base_url, auth_headers={})
- if "rerank" == model_uid:
+ if model_uid == "rerank":
return RESTfulRerankModelHandle(model_uid, base_url=self.base_url, auth_headers={})
raise RuntimeError("404 Not Found")
diff --git a/api/tests/integration_tests/tools/api_tool/test_api_tool.py b/api/tests/integration_tests/tools/api_tool/test_api_tool.py
index 09729a961ef..1bd75b91f74 100644
--- a/api/tests/integration_tests/tools/api_tool/test_api_tool.py
+++ b/api/tests/integration_tests/tools/api_tool/test_api_tool.py
@@ -34,9 +34,9 @@ def test_api_tool(setup_http_mock):
response = tool.do_http_request(tool.api_bundle.server_url, tool.api_bundle.method, headers, parameters)
assert response.status_code == 200
- assert "/p_param" == response.request.url.path
- assert b"query_param=q_param" == response.request.url.query
- assert "h_param" == response.request.headers.get("header_param")
- assert "application/json" == response.request.headers.get("content-type")
- assert "cookie_param=c_param" == response.request.headers.get("cookie")
+ assert response.request.url.path == "/p_param"
+ assert response.request.url.query == b"query_param=q_param"
+ assert response.request.headers.get("header_param") == "h_param"
+ assert response.request.headers.get("content-type") == "application/json"
+ assert response.request.headers.get("cookie") == "cookie_param=c_param"
assert "b_param" in response.content.decode()
diff --git a/api/tests/integration_tests/workflow/nodes/test_http.py b/api/tests/integration_tests/workflow/nodes/test_http.py
index 9eea63f722e..0507fc70756 100644
--- a/api/tests/integration_tests/workflow/nodes/test_http.py
+++ b/api/tests/integration_tests/workflow/nodes/test_http.py
@@ -384,7 +384,7 @@ def test_mock_404(setup_http_mock):
assert result.outputs is not None
resp = result.outputs
- assert 404 == resp.get("status_code")
+ assert resp.get("status_code") == 404
assert "Not Found" in resp.get("body", "")