fix: auto-fix code issues (cron)

- 修复隐式 Optional 类型注解 (RUF013)
- 修复不必要的赋值后返回 (RET504)
- 优化列表推导式 (PERF401)
- 修复未使用的参数 (ARG002)
- 清理重复导入
- 优化异常处理
This commit is contained in:
AutoFix Bot
2026-03-03 21:11:47 +08:00
parent d17a58ceae
commit 259f2c90d0
36 changed files with 1651 additions and 863 deletions

View File

@@ -129,7 +129,9 @@ class TestOpsManager:
# 更新告警规则
updated_rule = self.manager.update_alert_rule(
rule1.id, threshold=85.0, description="更新后的描述",
rule1.id,
threshold=85.0,
description="更新后的描述",
)
assert updated_rule.threshold == 85.0
self.log(f"Updated alert rule threshold to {updated_rule.threshold}")
@@ -421,7 +423,9 @@ class TestOpsManager:
# 模拟扩缩容评估
event = self.manager.evaluate_scaling_policy(
policy_id=policy.id, current_instances=3, current_utilization=0.85,
policy_id=policy.id,
current_instances=3,
current_utilization=0.85,
)
if event:
@@ -439,7 +443,8 @@ class TestOpsManager:
with self.manager._get_db() as conn:
conn.execute("DELETE FROM scaling_events WHERE tenant_id = ?", (self.tenant_id,))
conn.execute(
"DELETE FROM auto_scaling_policies WHERE tenant_id = ?", (self.tenant_id,),
"DELETE FROM auto_scaling_policies WHERE tenant_id = ?",
(self.tenant_id,),
)
conn.commit()
self.log("Cleaned up auto scaling test data")
@@ -530,7 +535,8 @@ class TestOpsManager:
# 发起故障转移
event = self.manager.initiate_failover(
config_id=config.id, reason="Primary region health check failed",
config_id=config.id,
reason="Primary region health check failed",
)
if event:
@@ -638,7 +644,9 @@ class TestOpsManager:
# 生成成本报告
now = datetime.now()
report = self.manager.generate_cost_report(
tenant_id=self.tenant_id, year=now.year, month=now.month,
tenant_id=self.tenant_id,
year=now.year,
month=now.month,
)
self.log(f"Generated cost report: {report.id}")
@@ -691,7 +699,8 @@ class TestOpsManager:
)
conn.execute("DELETE FROM idle_resources WHERE tenant_id = ?", (self.tenant_id,))
conn.execute(
"DELETE FROM resource_utilizations WHERE tenant_id = ?", (self.tenant_id,),
"DELETE FROM resource_utilizations WHERE tenant_id = ?",
(self.tenant_id,),
)
conn.execute("DELETE FROM cost_reports WHERE tenant_id = ?", (self.tenant_id,))
conn.commit()