From 963c725b82a408022a3842923030fd521020139b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= <zebuline@entrouvert.com>
Date: Mon, 30 Aug 2021 10:18:51 +0200
Subject: [PATCH 10/31] misc: fix logging-not-lazy pylint error (#56288)

---
 combo/apps/lingo/models.py | 31 +++++++++++++++++++------------
 combo/data/models.py       |  2 +-
 combo/utils/spooler.py     |  4 ++--
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py
index a1125693..ad268c94 100644
--- a/combo/apps/lingo/models.py
+++ b/combo/apps/lingo/models.py
@@ -230,7 +230,8 @@ class PaymentBackend(models.Model):
             raise UnknownPaymentException('Received unknown payment response')
         else:
             logger.debug(
-                'lingo: backend "%s" received payment response with id %%s' % self,
+                'lingo: backend "%s" received payment response with id %s',
+                self,
                 response.order_id,
                 extra=eopayment_response_to_extra_info(
                     response, lingo_transaction_id=transaction.pk, user=transaction.user
@@ -901,7 +902,7 @@ class Transaction(models.Model):
         return basket_item
 
     def handle_backend_response(self, response, callback=True):
-        logger.debug('lingo: regie "%s" handling response for transaction "%%s"' % self.regie, self.order_id)
+        logger.debug('lingo: regie "%s" handling response for transaction "%s"', self.regie, self.order_id)
         if self.status == response.result:
             # return early if self status didn't change (it means the
             # payment service sent the response both as server to server and
@@ -911,7 +912,8 @@ class Transaction(models.Model):
         if not self.is_running():
             logger.info(
                 'lingo: regie "%s" received payment notification on existing '
-                'transaction, status changed, "%%s" (%%s) -> "%%s" (%%s)' % self.regie,
+                'transaction, status changed, "%s" (%s) -> "%s" (%s)',
+                self.regie,
                 status_label(self.status),
                 self.status,
                 status_label(response.result),
@@ -922,7 +924,8 @@ class Transaction(models.Model):
             # we accept unsigned cancellation requests as some platforms do
             # that :/
             logger.warning(
-                'lingo: regie "%s" received unsigned payment response with id %%s' % self.regie,
+                'lingo: regie "%s" received unsigned payment response with id %s',
+                self.regie,
                 response.order_id,
             )
             raise UnsignedPaymentException(self, 'Received unsigned payment response')
@@ -939,8 +942,8 @@ class Transaction(models.Model):
             # XXX: don't know if it can happen, but we would like to know when it does
             # as for differed payments there can be multiple notifications.
             logger.error(
-                'lingo: regie "%s" new transaction_date for transaction %%s(%%s) was %%s, received %%s'
-                % self.regie,
+                'lingo: regie "%s" new transaction_date for transaction %s(%s) was %s, received %s',
+                self.regie,
                 self.order_id,
                 self.id,
                 self.bank_transaction_date,
@@ -950,8 +953,9 @@ class Transaction(models.Model):
         self.save()
 
         logger.info(
-            'lingo: regie "%s" received %s payment notification for transaction %%s(%%s)'
-            % (self.regie, 'synchronous' if callback else 'asynchronous'),
+            'lingo: regie "%s" received %s payment notification for transaction %s(%s)',
+            self.regie,
+            'synchronous' if callback else 'asynchronous',
             self.order_id,
             self.id,
             extra=eopayment_response_to_extra_info(response),
@@ -979,8 +983,9 @@ class Transaction(models.Model):
             except Exception as e:
                 # ignore errors, it will be retried later on if it fails
                 logger.warning(
-                    'lingo: regie "%s" error in sync notification for basket item %%s '
-                    'and transaction %%s, %%s' % self.regie,
+                    'lingo: regie "%s" error in sync notification for basket item %s '
+                    'and transaction %s, %s',
+                    self.regie,
                     item.id,
                     self.order_id,
                     e,
@@ -1015,7 +1020,8 @@ class Transaction(models.Model):
             except eopayment.PaymentException:
                 if ignore_errors:
                     logger.warning(
-                        'lingo: regie "%s" polling backend for transaction "%%s(%%s)" failed' % self.regie,
+                        'lingo: regie "%s" polling backend for transaction "%s(%s)" failed',
+                        self.regie,
                         self.order_id,
                         self.id,
                         exc_info=True,
@@ -1024,7 +1030,8 @@ class Transaction(models.Model):
                 raise PaymentException('polling failed')
 
             logger.debug(
-                'lingo: regie "%s" polling backend for transaction "%%s(%%s)"' % self.regie,
+                'lingo: regie "%s" polling backend for transaction "%s(%s)"',
+                self.regie,
                 self.order_id,
                 self.id,
             )
diff --git a/combo/data/models.py b/combo/data/models.py
index 00d16171..d52cc8a9 100644
--- a/combo/data/models.py
+++ b/combo/data/models.py
@@ -1249,7 +1249,7 @@ class TextCell(CellBase):
                 url = utils.get_templated_url(url, context=context)
             except utils.TemplateError as e:
                 logger = logging.getLogger(__name__)
-                logger.warning('error in templated URL (%s): %s' % (url, e))
+                logger.warning('error in templated URL (%s): %s', url, e)
             return '%s="%s"' % (attribute, url)
 
         text = re.sub(r'(href|src)="(.*?)"', sub_variadic_url, text)
diff --git a/combo/utils/spooler.py b/combo/utils/spooler.py
index 8ca417cd..179e0868 100644
--- a/combo/utils/spooler.py
+++ b/combo/utils/spooler.py
@@ -69,9 +69,9 @@ def tenantspool(func):
             try:
                 func(*args, **kwargs)
             except Exception:
-                logger.exception('spooler: exception during %s(%s, %s)' % (func.__name__, args, kwargs))
+                logger.exception('spooler: exception during %s(%s, %s)', func.__name__, args, kwargs)
             else:
-                logger.info('spooler: success of %s(%s, %s)' % (func.__name__, args, kwargs))
+                logger.info('spooler: success of %s(%s, %s)', func.__name__, args, kwargs)
 
     # pass arguments as pickles
     base_spooler = spool(pass_arguments=True)(spooler_func)
-- 
2.30.2

