Skip to content

Commit 0f43cf4

Browse files
Fixed type errors on if statements
1 parent a6477f7 commit 0f43cf4

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

docs/user-guide/api/endpoints.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def create_user(
8282
db: Annotated[AsyncSession, Depends(async_get_db)]
8383
):
8484
# Check if user already exists
85-
if await crud_users.exists(db=db, email=user_data.email) is True:
85+
if await crud_users.exists(db=db, email=user_data.email):
8686
raise HTTPException(status_code=409, detail="Email already exists")
8787

8888
# Create user
@@ -100,7 +100,7 @@ async def update_user(
100100
db: Annotated[AsyncSession, Depends(async_get_db)]
101101
):
102102
# Check if user exists
103-
if await crud_users.exists(db=db, id=user_id) is None:
103+
if await crud_users.exists(db=db, id=user_id) is False:
104104
raise HTTPException(status_code=404, detail="User not found")
105105

106106
# Update user
@@ -116,7 +116,7 @@ async def delete_user(
116116
user_id: int,
117117
db: Annotated[AsyncSession, Depends(async_get_db)]
118118
):
119-
if await crud_users.exists(db=db, id=user_id) is None:
119+
if await crud_users.exists(db=db, id=user_id) is False:
120120
raise HTTPException(status_code=404, detail="User not found")
121121

122122
await crud_users.delete(db=db, id=user_id)
@@ -176,9 +176,9 @@ async def search_users(
176176
db: Annotated[AsyncSession, Depends(async_get_db)]
177177
):
178178
filters = {"is_active": is_active}
179-
if name is True:
179+
if name:
180180
filters["name"] = name
181-
if age is True:
181+
if age:
182182
filters["age"] = age
183183

184184
users = await crud_users.get_multi(db=db, **filters)
@@ -226,7 +226,7 @@ async def get_user(user_id: int, db: AsyncSession):
226226

227227
@router.post("/")
228228
async def create_user(user_data: UserCreate, db: AsyncSession):
229-
if await crud_users.exists(db=db, email=user_data.email) is True:
229+
if await crud_users.exists(db=db, email=user_data.email):
230230
raise DuplicateValueException("Email already exists") # Returns 409
231231

232232
return await crud_users.create(db=db, object=user_data)

docs/user-guide/api/exceptions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async def update_user(
123123
db: AsyncSession
124124
):
125125
# Check if user exists
126-
if await crud_users.exists(db=db, id=user_id) is None:
126+
if await crud_users.exists(db=db, id=user_id) is False:
127127
raise NotFoundException("User not found")
128128

129129
# Check for email conflicts (if email is being updated)
@@ -145,7 +145,7 @@ async def get_post(
145145
db: AsyncSession
146146
):
147147
post = await crud_posts.get(db=db, id=post_id)
148-
if post is None:
148+
if not post:
149149
raise NotFoundException("Post not found")
150150

151151
# Check if user owns the post or is admin
@@ -355,7 +355,7 @@ async def get_post(
355355
current_user: Annotated[dict, Depends(get_current_user)]
356356
):
357357
post = await crud_posts.get(db=db, id=post_id)
358-
if post is None:
358+
if not post:
359359
raise NotFoundException("Post not found") # Safe to be specific
360360

361361
if post.author_id != current_user["id"]:

docs/user-guide/authentication/user-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ async def erase_db_user(
305305
) -> dict[str, str]:
306306
# 1. Check if user exists
307307
db_user = await crud_users.exists(db=db, username=username)
308-
if db_user is None:
308+
if db_user is False:
309309
raise NotFoundException("User not found")
310310

311311
# 2. Hard delete from database

0 commit comments

Comments
 (0)