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

@@ -120,7 +120,10 @@ class RateLimiter:
await counter.add_request()
return RateLimitInfo(
allowed=True, remaining=remaining - 1, reset_time=reset_time, retry_after=0,
allowed=True,
remaining=remaining - 1,
reset_time=reset_time,
retry_after=0,
)
async def get_limit_info(self, key: str) -> RateLimitInfo:
@@ -145,9 +148,9 @@ class RateLimiter:
allowed=current_count < config.requests_per_minute,
remaining=remaining,
reset_time=reset_time,
retry_after=max(0, config.window_size)
if current_count >= config.requests_per_minute
else 0,
retry_after=(
max(0, config.window_size) if current_count >= config.requests_per_minute else 0
),
)
def reset(self, key: str | None = None) -> None: