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.

refactor: clean away unnecessary-type-conversion (bool/str no-op wrappers) (#40822)

Nguyễn Phương7444f96a1d8f
diff --git a/api/commands/account.py b/api/commands/account.py
index 6751361a1a0..c81c9fb4526 100644
--- a/api/commands/account.py
+++ b/api/commands/account.py
@@ -20,7 +20,7 @@ def reset_password(email, new_password, password_confirm):
Reset password of owner account
Only available in SELF_HOSTED mode
"""
- if str(new_password).strip() != str(password_confirm).strip():
+ if new_password.strip() != password_confirm.strip():
click.echo(click.style("Passwords do not match.", fg="red"))
return
normalized_email = email.strip().lower()
@@ -62,7 +62,7 @@ def reset_email(email, new_email, email_confirm):
Replace account email
:return:
"""
- if str(new_email).strip() != str(email_confirm).strip():
+ if new_email.strip() != email_confirm.strip():
click.echo(click.style("New emails do not match.", fg="red"))
return
normalized_new_email = new_email.strip().lower()
diff --git a/api/core/workflow/nodes/agent_v2/runtime_feature_manifest.py b/api/core/workflow/nodes/agent_v2/runtime_feature_manifest.py
index 8fd2783f61f..8456711973c 100644
--- a/api/core/workflow/nodes/agent_v2/runtime_feature_manifest.py
+++ b/api/core/workflow/nodes/agent_v2/runtime_feature_manifest.py
@@ -36,9 +36,9 @@ def build_runtime_feature_manifest(agent_soul: AgentSoulConfig) -> dict[str, Any
soul_dump = agent_soul.model_dump(mode="json", exclude_none=True, exclude_defaults=True)
for section in sorted(RESERVED_AGENT_BACKEND_FEATURES):
value = _get_nested(soul_dump, section)
- has_value = bool(value)
+ has_value = value
if isinstance(value, dict):
- has_value = any(bool(item) for item in value.values())
+ has_value = any(item for item in value.values())
if has_value:
warnings.append(
{
diff --git a/api/repositories/workflow_collaboration_repository.py b/api/repositories/workflow_collaboration_repository.py
index d1d95d79b9d..b3184528bfc 100644
--- a/api/repositories/workflow_collaboration_repository.py
+++ b/api/repositories/workflow_collaboration_repository.py
@@ -139,10 +139,10 @@ class WorkflowCollaborationRepository:
self._redis.delete(self.sid_key(sid))
def session_exists(self, workflow_id: str, sid: str) -> bool:
- return bool(self._redis.hexists(self.workflow_key(workflow_id), sid))
+ return self._redis.hexists(self.workflow_key(workflow_id), sid)
def sid_mapping_exists(self, sid: str) -> bool:
- return bool(self._redis.exists(self.sid_key(sid)))
+ return self._redis.exists(self.sid_key(sid))
def get_session_sids(self, workflow_id: str) -> list[str]:
raw_sids = self._redis.hkeys(self.workflow_key(workflow_id))
@@ -237,7 +237,7 @@ class WorkflowCollaborationRepository:
self._redis.set(self.server_key(server_id), "1", ex=SERVER_HEARTBEAT_TTL_SECONDS)
def server_heartbeat_exists(self, server_id: str) -> bool:
- return bool(self._redis.exists(self.server_key(server_id)))
+ return bool(self._redis.exists(self.server_key(server_id))) # tests assert `is True`
def refresh_server_sessions(self, server_id: str) -> None:
"""Refresh Redis TTLs for sessions owned by a live websocket worker."""