@@ -51,7 +51,7 @@ def _parse_as_user(user_id: Any) -> UserID:
5151 try :
5252 return TypeAdapter (UserID ).validate_python (user_id )
5353 except ValidationError as err :
54- raise UserNotFoundError (uid = user_id , user_id = user_id ) from err
54+ raise UserNotFoundError (user_id = user_id ) from err
5555
5656
5757def _public_user_cols (caller_id : int ):
@@ -105,7 +105,7 @@ async def get_public_user(
105105 result = await conn .execute (query )
106106 user = result .first ()
107107 if not user :
108- raise UserNotFoundError (uid = user_id )
108+ raise UserNotFoundError (user_id = user_id )
109109 return user
110110
111111
@@ -165,7 +165,7 @@ async def get_user_or_raise(
165165 result = await conn .execute (query )
166166 row = result .first ()
167167 if row is None :
168- raise UserNotFoundError (uid = user_id )
168+ raise UserNotFoundError (user_id = user_id )
169169
170170 user : dict [str , Any ] = row ._asdict ()
171171 return user
@@ -181,7 +181,7 @@ async def get_user_primary_group_id(
181181 ).where (users .c .id == user_id )
182182 )
183183 if primary_gid is None :
184- raise UserNotFoundError (uid = user_id )
184+ raise UserNotFoundError (user_id = user_id )
185185 return primary_gid
186186
187187
@@ -193,15 +193,19 @@ async def get_users_ids_in_group(
193193) -> set [UserID ]:
194194 async with pass_or_acquire_connection (engine , connection ) as conn :
195195 result = await conn .stream (
196- sa .select (user_to_groups .c .uid ).where (user_to_groups .c .gid == group_id )
196+ sa .select (
197+ user_to_groups .c .uid ,
198+ ).where (user_to_groups .c .gid == group_id )
197199 )
198200 return {row .uid async for row in result }
199201
200202
201203async def get_user_id_from_pgid (app : web .Application , primary_gid : int ) -> UserID :
202204 async with pass_or_acquire_connection (engine = get_asyncpg_engine (app )) as conn :
203205 user_id : UserID = await conn .scalar (
204- sa .select (users .c .id ).where (users .c .primary_gid == primary_gid )
206+ sa .select (
207+ users .c .id ,
208+ ).where (users .c .primary_gid == primary_gid )
205209 )
206210 return user_id
207211
@@ -221,7 +225,7 @@ async def get_user_fullname(app: web.Application, *, user_id: UserID) -> FullNam
221225 )
222226 user = await result .first ()
223227 if not user :
224- raise UserNotFoundError (uid = user_id )
228+ raise UserNotFoundError (user_id = user_id )
225229
226230 return FullNameDict (
227231 first_name = user .first_name ,
@@ -234,7 +238,10 @@ async def get_guest_user_ids_and_names(
234238) -> list [tuple [UserID , UserNameID ]]:
235239 async with pass_or_acquire_connection (engine = get_asyncpg_engine (app )) as conn :
236240 result = await conn .stream (
237- sa .select (users .c .id , users .c .name ).where (users .c .role == UserRole .GUEST )
241+ sa .select (
242+ users .c .id ,
243+ users .c .name ,
244+ ).where (users .c .role == UserRole .GUEST )
238245 )
239246
240247 return TypeAdapter (list [tuple [UserID , UserNameID ]]).validate_python (
@@ -250,10 +257,12 @@ async def get_user_role(app: web.Application, *, user_id: UserID) -> UserRole:
250257
251258 async with pass_or_acquire_connection (engine = get_asyncpg_engine (app )) as conn :
252259 user_role = await conn .scalar (
253- sa .select (users .c .role ).where (users .c .id == user_id )
260+ sa .select (
261+ users .c .role ,
262+ ).where (users .c .id == user_id )
254263 )
255264 if user_role is None :
256- raise UserNotFoundError (uid = user_id )
265+ raise UserNotFoundError (user_id = user_id )
257266 assert isinstance (user_role , UserRole ) # nosec
258267 return user_role
259268
@@ -291,7 +300,9 @@ async def do_update_expired_users(
291300 async with transaction_context (engine , connection ) as conn :
292301 result = await conn .stream (
293302 users .update ()
294- .values (status = UserStatus .EXPIRED )
303+ .values (
304+ status = UserStatus .EXPIRED ,
305+ )
295306 .where (
296307 (users .c .expires_at .is_not (None ))
297308 & (users .c .status == UserStatus .ACTIVE )
@@ -311,7 +322,11 @@ async def update_user_status(
311322):
312323 async with transaction_context (engine , connection ) as conn :
313324 await conn .execute (
314- users .update ().values (status = new_status ).where (users .c .id == user_id )
325+ users .update ()
326+ .values (
327+ status = new_status ,
328+ )
329+ .where (users .c .id == user_id )
315330 )
316331
317332
@@ -325,7 +340,9 @@ async def search_users_and_get_profile(
325340 users_alias = sa .alias (users , name = "users_alias" )
326341
327342 invited_by = (
328- sa .select (users_alias .c .name )
343+ sa .select (
344+ users_alias .c .name ,
345+ )
329346 .where (users_pre_registration_details .c .created_by == users_alias .c .id )
330347 .label ("invited_by" )
331348 )
@@ -384,11 +401,19 @@ async def get_user_products(
384401) -> list [Row ]:
385402 async with pass_or_acquire_connection (engine , connection ) as conn :
386403 product_name_subq = (
387- sa .select (products .c .name )
404+ sa .select (
405+ products .c .name ,
406+ )
388407 .where (products .c .group_id == groups .c .gid )
389408 .label ("product_name" )
390409 )
391- products_gis_subq = sa .select (products .c .group_id ).distinct ().subquery ()
410+ products_gis_subq = (
411+ sa .select (
412+ products .c .group_id ,
413+ )
414+ .distinct ()
415+ .subquery ()
416+ )
392417 query = (
393418 sa .select (
394419 groups .c .gid ,
@@ -419,7 +444,9 @@ async def create_user_details(
419444 async with transaction_context (engine , connection ) as conn :
420445 await conn .execute (
421446 sa .insert (users_pre_registration_details ).values (
422- created_by = created_by , pre_email = email , ** other_values
447+ created_by = created_by ,
448+ pre_email = email ,
449+ ** other_values ,
423450 )
424451 )
425452
@@ -490,7 +517,7 @@ async def get_my_profile(app: web.Application, *, user_id: UserID) -> MyProfile:
490517 )
491518 row = await result .first ()
492519 if not row :
493- raise UserNotFoundError (uid = user_id )
520+ raise UserNotFoundError (user_id = user_id )
494521
495522 my_profile = MyProfile .model_validate (row , from_attributes = True )
496523 assert my_profile .id == user_id # nosec
0 commit comments