mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 01:29:04 +08:00
fix: remove ruff ignore SIM300 (#11810)
This commit is contained in:
parent
560d375e0f
commit
d057067543
@ -70,7 +70,6 @@ ignore = [
|
|||||||
"SIM113", # eumerate-for-loop
|
"SIM113", # eumerate-for-loop
|
||||||
"SIM117", # multiple-with-statements
|
"SIM117", # multiple-with-statements
|
||||||
"SIM210", # if-expr-with-true-false
|
"SIM210", # if-expr-with-true-false
|
||||||
"SIM300", # yoda-conditions,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[lint.per-file-ignores]
|
[lint.per-file-ignores]
|
||||||
|
@ -31,7 +31,7 @@ def admin_required(view):
|
|||||||
if auth_scheme != "bearer":
|
if auth_scheme != "bearer":
|
||||||
raise Unauthorized("Invalid Authorization header format. Expected 'Bearer <api-key>' format.")
|
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.")
|
raise Unauthorized("API key is invalid.")
|
||||||
|
|
||||||
return view(*args, **kwargs)
|
return view(*args, **kwargs)
|
||||||
|
@ -119,7 +119,7 @@ class ReplicateEmbeddingModel(_CommonReplicate, TextEmbeddingModel):
|
|||||||
embeddings.append(result[0].get("embedding"))
|
embeddings.append(result[0].get("embedding"))
|
||||||
|
|
||||||
return [list(map(float, e)) for e in embeddings]
|
return [list(map(float, e)) for e in embeddings]
|
||||||
elif "texts" == text_input_key:
|
elif text_input_key == "texts":
|
||||||
result = client.run(
|
result = client.run(
|
||||||
replicate_model_version,
|
replicate_model_version,
|
||||||
input={
|
input={
|
||||||
|
@ -21,13 +21,13 @@ class MockXinferenceClass:
|
|||||||
if not re.match(r"https?:\/\/[^\s\/$.?#].[^\s]*$", self.base_url):
|
if not re.match(r"https?:\/\/[^\s\/$.?#].[^\s]*$", self.base_url):
|
||||||
raise RuntimeError("404 Not Found")
|
raise RuntimeError("404 Not Found")
|
||||||
|
|
||||||
if "generate" == model_uid:
|
if model_uid == "generate":
|
||||||
return RESTfulGenerateModelHandle(model_uid, base_url=self.base_url, auth_headers={})
|
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={})
|
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={})
|
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={})
|
return RESTfulRerankModelHandle(model_uid, base_url=self.base_url, auth_headers={})
|
||||||
raise RuntimeError("404 Not Found")
|
raise RuntimeError("404 Not Found")
|
||||||
|
|
||||||
|
@ -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)
|
response = tool.do_http_request(tool.api_bundle.server_url, tool.api_bundle.method, headers, parameters)
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert "/p_param" == response.request.url.path
|
assert response.request.url.path == "/p_param"
|
||||||
assert b"query_param=q_param" == response.request.url.query
|
assert response.request.url.query == b"query_param=q_param"
|
||||||
assert "h_param" == response.request.headers.get("header_param")
|
assert response.request.headers.get("header_param") == "h_param"
|
||||||
assert "application/json" == response.request.headers.get("content-type")
|
assert response.request.headers.get("content-type") == "application/json"
|
||||||
assert "cookie_param=c_param" == response.request.headers.get("cookie")
|
assert response.request.headers.get("cookie") == "cookie_param=c_param"
|
||||||
assert "b_param" in response.content.decode()
|
assert "b_param" in response.content.decode()
|
||||||
|
@ -384,7 +384,7 @@ def test_mock_404(setup_http_mock):
|
|||||||
assert result.outputs is not None
|
assert result.outputs is not None
|
||||||
resp = result.outputs
|
resp = result.outputs
|
||||||
|
|
||||||
assert 404 == resp.get("status_code")
|
assert resp.get("status_code") == 404
|
||||||
assert "Not Found" in resp.get("body", "")
|
assert "Not Found" in resp.get("body", "")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user