fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解
This commit is contained in:
@@ -531,40 +531,40 @@ class EnterpriseManager:
|
||||
cursor.execute("CREATE INDEX IF NOT EXISTS idx_sso_tenant ON sso_configs(tenant_id)")
|
||||
cursor.execute("CREATE INDEX IF NOT EXISTS idx_sso_provider ON sso_configs(provider)")
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_saml_requests_config ON saml_auth_requests(sso_config_id)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_saml_requests_config ON saml_auth_requests(sso_config_id)",
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_saml_requests_expires ON saml_auth_requests(expires_at)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_saml_requests_expires ON saml_auth_requests(expires_at)",
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_saml_responses_request ON saml_auth_responses(request_id)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_saml_responses_request ON saml_auth_responses(request_id)",
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_scim_config_tenant ON scim_configs(tenant_id)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_scim_config_tenant ON scim_configs(tenant_id)",
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_scim_users_tenant ON scim_users(tenant_id)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_scim_users_tenant ON scim_users(tenant_id)",
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_scim_users_external ON scim_users(external_id)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_scim_users_external ON scim_users(external_id)",
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_audit_export_tenant ON audit_log_exports(tenant_id)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_audit_export_tenant ON audit_log_exports(tenant_id)",
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_audit_export_status ON audit_log_exports(status)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_audit_export_status ON audit_log_exports(status)",
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_retention_tenant ON data_retention_policies(tenant_id)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_retention_tenant ON data_retention_policies(tenant_id)",
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_retention_type ON data_retention_policies(resource_type)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_retention_type ON data_retention_policies(resource_type)",
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_retention_jobs_policy ON data_retention_jobs(policy_id)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_retention_jobs_policy ON data_retention_jobs(policy_id)",
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_retention_jobs_status ON data_retention_jobs(status)"
|
||||
"CREATE INDEX IF NOT EXISTS idx_retention_jobs_status ON data_retention_jobs(status)",
|
||||
)
|
||||
|
||||
conn.commit()
|
||||
@@ -699,7 +699,7 @@ class EnterpriseManager:
|
||||
conn.close()
|
||||
|
||||
def get_tenant_sso_config(
|
||||
self, tenant_id: str, provider: str | None = None
|
||||
self, tenant_id: str, provider: str | None = None,
|
||||
) -> SSOConfig | None:
|
||||
"""获取租户的 SSO 配置"""
|
||||
conn = self._get_connection()
|
||||
@@ -871,7 +871,7 @@ class EnterpriseManager:
|
||||
return metadata
|
||||
|
||||
def create_saml_auth_request(
|
||||
self, tenant_id: str, config_id: str, relay_state: str | None = None
|
||||
self, tenant_id: str, config_id: str, relay_state: str | None = None,
|
||||
) -> SAMLAuthRequest:
|
||||
"""创建 SAML 认证请求"""
|
||||
conn = self._get_connection()
|
||||
@@ -1235,7 +1235,7 @@ class EnterpriseManager:
|
||||
return []
|
||||
|
||||
def _upsert_scim_user(
|
||||
self, conn: sqlite3.Connection, tenant_id: str, user_data: dict[str, Any]
|
||||
self, conn: sqlite3.Connection, tenant_id: str, user_data: dict[str, Any],
|
||||
) -> None:
|
||||
"""插入或更新 SCIM 用户"""
|
||||
cursor = conn.cursor()
|
||||
@@ -1405,7 +1405,7 @@ class EnterpriseManager:
|
||||
try:
|
||||
# 获取审计日志数据
|
||||
logs = self._fetch_audit_logs(
|
||||
export.tenant_id, export.start_date, export.end_date, export.filters, db_manager
|
||||
export.tenant_id, export.start_date, export.end_date, export.filters, db_manager,
|
||||
)
|
||||
|
||||
# 根据合规标准过滤字段
|
||||
@@ -1414,7 +1414,7 @@ class EnterpriseManager:
|
||||
|
||||
# 生成导出文件
|
||||
file_path, file_size, checksum = self._generate_export_file(
|
||||
export_id, logs, export.export_format
|
||||
export_id, logs, export.export_format,
|
||||
)
|
||||
|
||||
now = datetime.now()
|
||||
@@ -1465,7 +1465,7 @@ class EnterpriseManager:
|
||||
return []
|
||||
|
||||
def _apply_compliance_filter(
|
||||
self, logs: list[dict[str, Any]], standard: str
|
||||
self, logs: list[dict[str, Any]], standard: str,
|
||||
) -> list[dict[str, Any]]:
|
||||
"""应用合规标准字段过滤"""
|
||||
fields = self.COMPLIANCE_FIELDS.get(ComplianceStandard(standard), [])
|
||||
@@ -1481,7 +1481,7 @@ class EnterpriseManager:
|
||||
return filtered_logs
|
||||
|
||||
def _generate_export_file(
|
||||
self, export_id: str, logs: list[dict[str, Any]], format: str
|
||||
self, export_id: str, logs: list[dict[str, Any]], format: str,
|
||||
) -> tuple[str, int, str]:
|
||||
"""生成导出文件"""
|
||||
import hashlib
|
||||
@@ -1672,7 +1672,7 @@ class EnterpriseManager:
|
||||
conn.close()
|
||||
|
||||
def list_retention_policies(
|
||||
self, tenant_id: str, resource_type: str | None = None
|
||||
self, tenant_id: str, resource_type: str | None = None,
|
||||
) -> list[DataRetentionPolicy]:
|
||||
"""列出数据保留策略"""
|
||||
conn = self._get_connection()
|
||||
@@ -1876,7 +1876,7 @@ class EnterpriseManager:
|
||||
conn.close()
|
||||
|
||||
def _retain_audit_logs(
|
||||
self, conn: sqlite3.Connection, policy: DataRetentionPolicy, cutoff_date: datetime
|
||||
self, conn: sqlite3.Connection, policy: DataRetentionPolicy, cutoff_date: datetime,
|
||||
) -> dict[str, int]:
|
||||
"""保留审计日志"""
|
||||
cursor = conn.cursor()
|
||||
@@ -1909,14 +1909,14 @@ class EnterpriseManager:
|
||||
return {"affected": 0, "archived": 0, "deleted": 0, "errors": 0}
|
||||
|
||||
def _retain_projects(
|
||||
self, conn: sqlite3.Connection, policy: DataRetentionPolicy, cutoff_date: datetime
|
||||
self, conn: sqlite3.Connection, policy: DataRetentionPolicy, cutoff_date: datetime,
|
||||
) -> dict[str, int]:
|
||||
"""保留项目数据"""
|
||||
# 简化实现
|
||||
return {"affected": 0, "archived": 0, "deleted": 0, "errors": 0}
|
||||
|
||||
def _retain_transcripts(
|
||||
self, conn: sqlite3.Connection, policy: DataRetentionPolicy, cutoff_date: datetime
|
||||
self, conn: sqlite3.Connection, policy: DataRetentionPolicy, cutoff_date: datetime,
|
||||
) -> dict[str, int]:
|
||||
"""保留转录数据"""
|
||||
# 简化实现
|
||||
|
||||
Reference in New Issue
Block a user