chore(quality): apply ruff autofixes and formatting (223 fixes, regression-free: 118/118 tests pass)
This commit is contained in:
+20
-18
@@ -2,8 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, Response, status
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@@ -19,11 +17,23 @@ from app.schemas.activity import (
|
||||
)
|
||||
from app.services.activity_service import (
|
||||
NoParentException,
|
||||
)
|
||||
from app.services.activity_service import (
|
||||
complete_activity as svc_complete_activity,
|
||||
)
|
||||
from app.services.activity_service import (
|
||||
create_activity as svc_create_activity,
|
||||
)
|
||||
from app.services.activity_service import (
|
||||
get_activity as svc_get_activity,
|
||||
)
|
||||
from app.services.activity_service import (
|
||||
list_activities as svc_list_activities,
|
||||
)
|
||||
from app.services.activity_service import (
|
||||
soft_delete_activity as svc_soft_delete_activity,
|
||||
)
|
||||
from app.services.activity_service import (
|
||||
update_activity as svc_update_activity,
|
||||
)
|
||||
|
||||
@@ -58,10 +68,10 @@ async def create_activity(
|
||||
async def list_activities(
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(20, ge=1, le=100),
|
||||
type: Optional[ActivityType] = None,
|
||||
owner_id: Optional[int] = None,
|
||||
overdue: Optional[bool] = None,
|
||||
completed: Optional[bool] = None,
|
||||
type: ActivityType | None = None,
|
||||
owner_id: int | None = None,
|
||||
overdue: bool | None = None,
|
||||
completed: bool | None = None,
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> list[ActivityOut]:
|
||||
@@ -88,9 +98,7 @@ async def get_activity(
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> ActivityOut:
|
||||
activity = await svc_get_activity(
|
||||
db, activity_id, org_id=current_user.org_id
|
||||
)
|
||||
activity = await svc_get_activity(db, activity_id, org_id=current_user.org_id)
|
||||
if activity is None:
|
||||
raise HTTPException(status_code=404, detail="Activity not found")
|
||||
return ActivityOut.model_validate(activity)
|
||||
@@ -107,9 +115,7 @@ async def update_activity(
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> ActivityOut:
|
||||
activity = await svc_get_activity(
|
||||
db, activity_id, org_id=current_user.org_id
|
||||
)
|
||||
activity = await svc_get_activity(db, activity_id, org_id=current_user.org_id)
|
||||
if activity is None:
|
||||
raise HTTPException(status_code=404, detail="Activity not found")
|
||||
try:
|
||||
@@ -130,9 +136,7 @@ async def complete_activity(
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> ActivityOut:
|
||||
activity = await svc_get_activity(
|
||||
db, activity_id, org_id=current_user.org_id
|
||||
)
|
||||
activity = await svc_get_activity(db, activity_id, org_id=current_user.org_id)
|
||||
if activity is None:
|
||||
raise HTTPException(status_code=404, detail="Activity not found")
|
||||
updated = await svc_complete_activity(db, activity, payload)
|
||||
@@ -150,9 +154,7 @@ async def delete_activity(
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> Response:
|
||||
activity = await svc_get_activity(
|
||||
db, activity_id, org_id=current_user.org_id
|
||||
)
|
||||
activity = await svc_get_activity(db, activity_id, org_id=current_user.org_id)
|
||||
if activity is None:
|
||||
raise HTTPException(status_code=404, detail="Activity not found")
|
||||
await svc_soft_delete_activity(db, activity)
|
||||
|
||||
Reference in New Issue
Block a user