File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -132,4 +132,6 @@ cython_debug/
132132
133133.ruff_cache
134134
135- .idea
135+ .idea
136+
137+ .vscode /
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ from app.core.exceptions.http_exceptions import ForbiddenException
6363async def delete_user (
6464 user_id : int ,
6565 current_user : Annotated[dict , Depends(get_current_user)]
66- ):
66+ ):
6767 if current_user[" id" ] != user_id and not current_user[" is_superuser" ]:
6868 raise ForbiddenException(" You can only delete your own account" )
6969
@@ -121,7 +121,7 @@ async def update_user(
121121 user_id : int ,
122122 user_data : UserUpdate,
123123 db : AsyncSession
124- ):
124+ ):
125125 # Check if user exists
126126 if not await crud_users.exists(db = db, id = user_id):
127127 raise NotFoundException(" User not found" )
@@ -143,7 +143,7 @@ async def get_post(
143143 post_id : int ,
144144 current_user : Annotated[dict , Depends(get_current_user)],
145145 db : AsyncSession
146- ):
146+ ):
147147 post = await crud_posts.get(db = db, id = post_id)
148148 if not post:
149149 raise NotFoundException(" Post not found" )
@@ -155,6 +155,10 @@ async def get_post(
155155 return post
156156```
157157
158+ > ** Note:**
159+ > Some CRUD helper functions may evolve to return falsy-but-valid values (e.g. empty objects).
160+ > To future-proof your API, prefer ` if post is None: ` instead of ` if not post: ` when checking existence.
161+
158162## Validation Errors
159163
160164FastAPI automatically handles Pydantic validation errors, but you can catch and customize them:
You can’t perform that action at this time.
0 commit comments