fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解
This commit is contained in:
@@ -220,7 +220,7 @@ class PluginManager:
|
||||
return None
|
||||
|
||||
def list_plugins(
|
||||
self, project_id: str = None, plugin_type: str = None, status: str = None
|
||||
self, project_id: str = None, plugin_type: str = None, status: str = None,
|
||||
) -> list[Plugin]:
|
||||
"""列出插件"""
|
||||
conn = self.db.get_conn()
|
||||
@@ -241,7 +241,7 @@ class PluginManager:
|
||||
where_clause = " AND ".join(conditions) if conditions else "1 = 1"
|
||||
|
||||
rows = conn.execute(
|
||||
f"SELECT * FROM plugins WHERE {where_clause} ORDER BY created_at DESC", params
|
||||
f"SELECT * FROM plugins WHERE {where_clause} ORDER BY created_at DESC", params,
|
||||
).fetchall()
|
||||
conn.close()
|
||||
|
||||
@@ -310,7 +310,7 @@ class PluginManager:
|
||||
# ==================== Plugin Config ====================
|
||||
|
||||
def set_plugin_config(
|
||||
self, plugin_id: str, key: str, value: str, is_encrypted: bool = False
|
||||
self, plugin_id: str, key: str, value: str, is_encrypted: bool = False,
|
||||
) -> PluginConfig:
|
||||
"""设置插件配置"""
|
||||
conn = self.db.get_conn()
|
||||
@@ -367,7 +367,7 @@ class PluginManager:
|
||||
"""获取插件所有配置"""
|
||||
conn = self.db.get_conn()
|
||||
rows = conn.execute(
|
||||
"SELECT config_key, config_value FROM plugin_configs WHERE plugin_id = ?", (plugin_id,)
|
||||
"SELECT config_key, config_value FROM plugin_configs WHERE plugin_id = ?", (plugin_id,),
|
||||
).fetchall()
|
||||
conn.close()
|
||||
|
||||
@@ -377,7 +377,7 @@ class PluginManager:
|
||||
"""删除插件配置"""
|
||||
conn = self.db.get_conn()
|
||||
cursor = conn.execute(
|
||||
"DELETE FROM plugin_configs WHERE plugin_id = ? AND config_key = ?", (plugin_id, key)
|
||||
"DELETE FROM plugin_configs WHERE plugin_id = ? AND config_key = ?", (plugin_id, key),
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
@@ -512,7 +512,7 @@ class ChromeExtensionHandler:
|
||||
"""撤销令牌"""
|
||||
conn = self.pm.db.get_conn()
|
||||
cursor = conn.execute(
|
||||
"UPDATE chrome_extension_tokens SET is_revoked = 1 WHERE id = ?", (token_id,)
|
||||
"UPDATE chrome_extension_tokens SET is_revoked = 1 WHERE id = ?", (token_id,),
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
@@ -520,7 +520,7 @@ class ChromeExtensionHandler:
|
||||
return cursor.rowcount > 0
|
||||
|
||||
def list_tokens(
|
||||
self, user_id: str = None, project_id: str = None
|
||||
self, user_id: str = None, project_id: str = None,
|
||||
) -> list[ChromeExtensionToken]:
|
||||
"""列出令牌"""
|
||||
conn = self.pm.db.get_conn()
|
||||
@@ -558,7 +558,7 @@ class ChromeExtensionHandler:
|
||||
last_used_at=row["last_used_at"],
|
||||
use_count=row["use_count"],
|
||||
is_revoked=bool(row["is_revoked"]),
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
return tokens
|
||||
@@ -897,12 +897,12 @@ class BotHandler:
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(
|
||||
session.webhook_url, json=payload, headers={"Content-Type": "application/json"}
|
||||
session.webhook_url, json=payload, headers={"Content-Type": "application/json"},
|
||||
)
|
||||
return response.status_code == 200
|
||||
|
||||
async def _send_dingtalk_message(
|
||||
self, session: BotSession, message: str, msg_type: str
|
||||
self, session: BotSession, message: str, msg_type: str,
|
||||
) -> bool:
|
||||
"""发送钉钉消息"""
|
||||
timestamp = str(round(time.time() * 1000))
|
||||
@@ -928,7 +928,7 @@ class BotHandler:
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(
|
||||
url, json=payload, headers={"Content-Type": "application/json"}
|
||||
url, json=payload, headers={"Content-Type": "application/json"},
|
||||
)
|
||||
return response.status_code == 200
|
||||
|
||||
@@ -1115,7 +1115,7 @@ class WebhookIntegration:
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(
|
||||
endpoint.endpoint_url, json=payload, headers=headers, timeout=30.0
|
||||
endpoint.endpoint_url, json=payload, headers=headers, timeout=30.0,
|
||||
)
|
||||
|
||||
success = response.status_code in [200, 201, 202]
|
||||
@@ -1343,7 +1343,7 @@ class WebDAVSyncManager:
|
||||
remote_project_path = f"{sync.remote_path}/{sync.project_id}"
|
||||
try:
|
||||
client.mkdir(remote_project_path)
|
||||
except (OSError, IOError):
|
||||
except OSError:
|
||||
pass # 目录可能已存在
|
||||
|
||||
# 获取项目数据
|
||||
|
||||
Reference in New Issue
Block a user