mirror of
https://github.com/langgenius/dify.git
synced 2026-08-29 03:45:08 +08:00
refactor: clean away unnecessary-type-conversion (bool/str no-op wrappers) (#40822)
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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(
|
||||
{
|
||||
|
||||
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user