Replace more f-strings

This commit is contained in:
PCoder 2025-05-21 11:27:22 +05:30
parent b6239159b2
commit 8ffa2d9c3c

View file

@ -774,8 +774,10 @@ class UserCardDetail(AssignPermissionsMixin, models.Model):
if user_card_details.count() > 1: if user_card_details.count() > 1:
# Log a warning about the duplicate entries # Log a warning about the duplicate entries
logger.warning( logger.warning(
f"Multiple UserCardDetail objects found for stripe_customer_id={stripe_cust.id} and card_id={card_id}. " "Multiple UserCardDetail objects found for stripe_customer_id={} and card_id={}. "
f"Found {user_card_details.count()} objects. Using the first one." "Found {} objects. Using the first one.".format(
stripe_cust.id, card_id, user_card_details.count()
)
) )
# Use the first object found # Use the first object found
user_card_detail = user_card_details.first() user_card_detail = user_card_details.first()
@ -787,13 +789,19 @@ class UserCardDetail(AssignPermissionsMixin, models.Model):
# Depending on expected behavior, you might want to raise an error or handle this case. # Depending on expected behavior, you might want to raise an error or handle this case.
# If the original get() call happened here, it would raise DoesNotExist. # If the original get() call happened here, it would raise DoesNotExist.
logger.error( logger.error(
f"No UserCardDetail found for stripe_customer_id={stripe_cust.id} and card_id={card_id}." "No UserCardDetail found for stripe_customer_id={} and card_id={}.".format(
stripe_cust.id, card_id
)
)
raise UserCardDetail.DoesNotExist(
"No UserCardDetail found for customer {}, card {}".format(
stripe_cust.id, card_id
)
) )
raise UserCardDetail.DoesNotExist(f"No UserCardDetail found for customer {stripe_cust.id}, card {card_id}")
except Exception as e: except Exception as e:
# Catch other potential exceptions during the filter/get process if necessary # Catch other potential exceptions during the filter/get process if necessary
logger.error(f"An unexpected error occurred while fetching UserCardDetail: {e}") logger.error("An unexpected error occurred while fetching UserCardDetail: {}".format(e))
raise raise
return user_card_detail return user_card_detail