chore(linter): make linter happy

This commit is contained in:
MingxuanGame
2025-09-30 07:57:08 +00:00
parent 0f637446df
commit 017b058e63
15 changed files with 99 additions and 120 deletions

View File

@@ -17,13 +17,14 @@ from app.models.totp import FinishStatus, StartCreateTotpKeyResp
from .router import router
from fastapi import Body, Depends, HTTPException, Security
import pyotp
from pydantic import BaseModel
import pyotp
from redis.asyncio import Redis
class TotpStatusResp(BaseModel):
"""TOTP状态响应"""
enabled: bool
created_at: str | None = None
@@ -42,10 +43,7 @@ async def get_totp_status(
totp_key = await current_user.awaitable_attrs.totp_key
if totp_key:
return TotpStatusResp(
enabled=True,
created_at=totp_key.created_at.isoformat()
)
return TotpStatusResp(enabled=True, created_at=totp_key.created_at.isoformat())
else:
return TotpStatusResp(enabled=False)

View File

@@ -354,7 +354,7 @@ async def get_user_ranking(
wheres.append(col(UserStatistics.user).has(country_code=country.upper()))
# 查询总数
count_query = select(func.count(UserStatistics.id)).where(*wheres)
count_query = select(func.count()).select_from(UserStatistics).where(*wheres)
total_count_result = await session.exec(count_query)
total_count = total_count_result.one()

View File

@@ -86,7 +86,7 @@ async def verify_session(
if verify_method is None:
# 智能选择验证方法参考osu-web实现
# API版本较老或用户未设置TOTP时强制使用邮件验证
#print(api_version, totp_key)
# print(api_version, totp_key)
if api_version < 20240101 or totp_key is None:
verify_method = "mail"
else:
@@ -153,11 +153,11 @@ async def verify_session(
}
# 如果有具体的错误原因,添加到响应中
if hasattr(e, 'reason') and e.reason:
if hasattr(e, "reason") and e.reason:
error_response["reason"] = e.reason
# 如果需要重新发送邮件验证码
if hasattr(e, 'should_reissue') and e.should_reissue and verify_method == "mail":
if hasattr(e, "should_reissue") and e.should_reissue and verify_method == "mail":
try:
await EmailVerificationService.send_verification_email(
db, redis, user_id, current_user.username, current_user.email, ip_address, user_agent