Skip to content

Commit

Permalink
fix: remove ruff ignore SIM300 (#11810)
Browse files Browse the repository at this point in the history
  • Loading branch information
barabicu authored Dec 19, 2024
1 parent 560d375 commit d057067
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion api/.ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/console/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def decorated(*args, **kwargs):
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _generate_embeddings_by_text_input_key(
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={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ def get_chat_model(self: Client, model_uid: str) -> Union[RESTfulGenerateModelHa
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")

Expand Down
10 changes: 5 additions & 5 deletions api/tests/integration_tests/tools/api_tool/test_api_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion api/tests/integration_tests/workflow/nodes/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")


Expand Down

0 comments on commit d057067

Please sign in to comment.