chore(quality): apply ruff autofixes and formatting (223 fixes, regression-free: 118/118 tests pass)

This commit is contained in:
Agent Zero
2026-06-10 21:24:24 +00:00
parent c53af91d74
commit aec40d03ac
56 changed files with 459 additions and 528 deletions
+2 -6
View File
@@ -42,9 +42,7 @@ async def get_current_user(
raise credentials_exc from None
# Load user fresh from DB to honor soft-delete and role changes
result = await db.execute(
select(User).where(User.id == user_id, User.deleted_at.is_(None))
)
result = await db.execute(select(User).where(User.id == user_id, User.deleted_at.is_(None)))
user = result.scalar_one_or_none()
if user is None:
@@ -57,9 +55,7 @@ async def get_current_admin_user(
user: User = Depends(get_current_user),
) -> User:
"""Require the current user to have the admin role."""
user_role = (
user.role.value if hasattr(user.role, "value") else str(user.role)
)
user_role = user.role.value if hasattr(user.role, "value") else str(user.role)
if user_role != UserRole.admin.value:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
+1 -3
View File
@@ -91,9 +91,7 @@ def is_token_expired(token: str) -> bool:
try:
jwt.get_unverified_claims(token)
# If decode succeeds, it's not expired.
jwt.decode(
token, _settings.AUTH_SECRET, algorithms=[_settings.JWT_ALGORITHM]
)
jwt.decode(token, _settings.AUTH_SECRET, algorithms=[_settings.JWT_ALGORITHM])
return False
except JWTError as e:
return "expired" in str(e).lower() or "exp" in str(e).lower()