Fix HTTP 204 status code response handling

- Remove return None from delete endpoints with 204 status code
- HTTP status code 204 must not have a response body per HTTP spec
- Fixed in both users.py and todos.py API endpoints
- Addresses AssertionError: Status code 204 must not have a response body
This commit is contained in:
Automated Action 2025-05-16 02:27:18 +00:00
parent 62288e3929
commit 4f79f6c29a
2 changed files with 3 additions and 5 deletions

View File

@ -84,5 +84,4 @@ def delete_todo(
""" """
success = todo_crud.delete_todo(db, todo_id=todo_id, owner_id=current_user.id) success = todo_crud.delete_todo(db, todo_id=todo_id, owner_id=current_user.id)
if not success: if not success:
raise HTTPException(status_code=404, detail="Todo not found") raise HTTPException(status_code=404, detail="Todo not found")
return None

View File

@ -74,7 +74,7 @@ def delete_user_endpoint(
user_id: int, user_id: int,
db: Session = Depends(get_db), db: Session = Depends(get_db),
current_user: User = Depends(get_current_active_user), current_user: User = Depends(get_current_active_user),
) -> Any: ):
""" """
Delete a user. Delete a user.
""" """
@ -87,5 +87,4 @@ def delete_user_endpoint(
success = delete_user(db, user_id=user_id) success = delete_user(db, user_id=user_id)
if not success: if not success:
raise HTTPException(status_code=404, detail="User not found") raise HTTPException(status_code=404, detail="User not found")
return None