@@ -230,10 +230,7 @@ def _get_or_add_by_phone_number_and_client_id(
230230 provenance = Provenance .SMS ,
231231 )
232232 logger .info (
233- "New auth user (id: {}) created by phone number (client_id: {})" .format (
234- row .id ,
235- client_id ,
236- ),
233+ f"New auth user (id: { row .id } ) created by phone number (client_id: { client_id } )"
237234 )
238235
239236 return row
@@ -261,10 +258,7 @@ def _add_by_email_and_client_id(
261258 user_type = user_type ,
262259 ):
263260 logger .exception (
264- "User duplication for email: {} (client_id: {})" .format (
265- email ,
266- client_id ,
267- ),
261+ f"User duplication for email: { email } (client_id: { client_id } )"
268262 )
269263 raise DuplicateAuthUser ()
270264
@@ -276,10 +270,7 @@ def _add_by_email_and_client_id(
276270 ** kwargs ,
277271 )
278272 logger .info (
279- "New auth user (id: {}) created by email (client_id: {})" .format (
280- row .id ,
281- client_id ,
282- ),
273+ f"New auth user (id: { row .id } ) created by email (client_id: { client_id } )"
283274 )
284275
285276 return row
@@ -305,10 +296,7 @@ def _add_by_client_id(
305296 date_verified = datetime .utcnow () if is_verified else None ,
306297 )
307298 logger .info (
308- "New auth user (id: {}) created by (client_id: {})" .format (
309- row .id ,
310- client_id ,
311- ),
299+ f"New auth user (id: { row .id } ) created by (client_id: { client_id } )"
312300 )
313301
314302 return row
@@ -559,20 +547,21 @@ def _get_by_client_ids_and_user_type(
559547 offset = None ,
560548 limit = None ,
561549 ):
562- if not client_ids :
563- return []
564-
565- return self ._repository .get_by (
566- session ,
567- filters = [
568- auth_user_model .client_id .in_ (client_ids ),
569- auth_user_model .user_type == user_type ,
570- # auth_user_model.is_active == True, # noqa: E712,
571- auth_user_model .date_verified != None ,
572- ],
573- offset = offset ,
574- limit = limit ,
575- order_by_clause = auth_user_model .id .desc (),
550+ return (
551+ self ._repository .get_by (
552+ session ,
553+ filters = [
554+ auth_user_model .client_id .in_ (client_ids ),
555+ auth_user_model .user_type == user_type ,
556+ # auth_user_model.is_active == True, # noqa: E712,
557+ auth_user_model .date_verified != None ,
558+ ],
559+ offset = offset ,
560+ limit = limit ,
561+ order_by_clause = auth_user_model .id .desc (),
562+ )
563+ if client_ids
564+ else []
576565 )
577566
578567 # get_by_client_ids_and_user_type = with_db_session(ro=True)(
@@ -597,7 +586,7 @@ def _get_by_client_id_with_substring_search(
597586 or_ (
598587 auth_user_model .provenance == Provenance .SMS ,
599588 auth_user_model .provenance == Provenance .LINK ,
600- auth_user_model .provenance == None , # noqa: E711
589+ auth_user_model .provenance is None ,
601590 ),
602591 or_ (
603592 auth_user_model .phone_number .contains (substring ),
@@ -691,7 +680,8 @@ def _get_by_email_for_interop(
691680 .options (contains_eager (auth_user_model .wallets ))
692681 .join (
693682 auth_user_model .magic_client .and_ (
694- magic_client_model .connect_interop == ConnectInteropStatus .ENABLED ,
683+ magic_client_model .connect_interop
684+ == ConnectInteropStatus .ENABLED ,
695685 ),
696686 )
697687 .options (contains_eager (auth_user_model .magic_client ))
@@ -708,8 +698,7 @@ def _get_by_email_for_interop(
708698 .filter (
709699 auth_user_model .email == email ,
710700 auth_user_model .user_type == EntityType .MAGIC .value ,
711- # auth_user_model.is_active == 1,
712- auth_user_model .linked_primary_auth_user_id == None , # noqa: E711
701+ auth_user_model .linked_primary_auth_user_id is None ,
713702 )
714703 .populate_existing ()
715704 )
@@ -764,7 +753,7 @@ def _add(
764753 management_type = None ,
765754 auth_user_id = None ,
766755 ):
767- new_row = self ._repository .add (
756+ return self ._repository .add (
768757 session ,
769758 auth_user_id = auth_user_id ,
770759 public_address = public_address ,
@@ -774,8 +763,6 @@ def _add(
774763 network = network ,
775764 )
776765
777- return new_row
778-
779766 # add = with_db_session(ro=False)(_add)
780767 add = _add
781768
@@ -813,10 +800,7 @@ def get_by_public_address(self, session, public_address, network=None, is_active
813800
814801 row = self ._repository .get_by (session , filters = filters , allow_inactive = not is_active )
815802
816- if not row :
817- return None
818-
819- return one (row )
803+ return one (row ) if row else None
820804
821805 # @with_db_session(ro=True)
822806 def get_by_auth_user_id (
@@ -857,10 +841,7 @@ def get_by_auth_user_id(
857841 session , filters = filters , join_list = join_list , allow_inactive = not is_active
858842 )
859843
860- if not rows :
861- return []
862-
863- return rows
844+ return rows or []
864845
865846 def _update_by_id (self , session , model_id , ** kwargs ):
866847 self ._repository .update (session , model_id , ** kwargs )
0 commit comments