@@ -130,7 +130,7 @@ username_taken = await crud_users.exists(db=db, username="john_doe")
130130``` python
131131# From src/app/api/v1/users.py - checking before creating
132132email_row = await crud_users.exists(db = db, email = user.email)
133- if email_row:
133+ if email_row is True :
134134 raise DuplicateValueException(" Email is already registered" )
135135```
136136
@@ -223,7 +223,7 @@ Update with validation:
223223# From real endpoint - check before updating
224224if values.username != db_user.username:
225225 existing_username = await crud_users.exists(db = db, username = values.username)
226- if existing_username:
226+ if existing_username is True :
227227 raise DuplicateValueException(" Username not available" )
228228
229229await crud_users.update(db = db, object = values, username = username)
@@ -423,10 +423,10 @@ from app.core.exceptions.http_exceptions import NotFoundException, DuplicateValu
423423
424424async def safe_user_creation (db : AsyncSession, user_data : UserCreate):
425425 # Check for duplicates
426- if await crud_users.exists(db = db, email = user_data.email):
426+ if await crud_users.exists(db = db, email = user_data.email) is True :
427427 raise DuplicateValueException(" Email already registered" )
428428
429- if await crud_users.exists(db = db, username = user_data.username):
429+ if await crud_users.exists(db = db, username = user_data.username) is True :
430430 raise DuplicateValueException(" Username not available" )
431431
432432 # Create user
@@ -475,12 +475,12 @@ Use `exists()` instead of `get()` when you only need to check existence:
475475
476476``` python
477477# Good - faster, doesn't load data
478- if await crud_users.exists(db = db, email = email):
478+ if await crud_users.exists(db = db, email = email) is True :
479479 raise DuplicateValueException(" Email taken" )
480480
481481# Avoid - slower, loads unnecessary data
482482user = await crud_users.get(db = db, email = email)
483- if user:
483+ if user is True :
484484 raise DuplicateValueException(" Email taken" )
485485```
486486
0 commit comments