From 8c19af5af2d32034347417f1e62ccc406ca1321a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= <zebuline@entrouvert.com>
Date: Fri, 20 Aug 2021 16:34:18 +0200
Subject: [PATCH 05/31] misc: fix unused-variable pylint error (#56288)

---
 combo/apps/assets/api_views.py     |  2 +-
 combo/apps/assets/models.py        |  2 +-
 combo/apps/assets/utils.py         |  4 ++--
 combo/apps/assets/views.py         |  2 +-
 combo/apps/calendar/utils.py       |  2 +-
 combo/apps/dashboard/views.py      |  1 -
 combo/apps/dataviz/forms.py        |  2 +-
 combo/apps/dataviz/utils.py        |  2 --
 combo/apps/dataviz/views.py        |  2 +-
 combo/apps/lingo/models.py         |  2 +-
 combo/apps/maps/models.py          |  2 +-
 combo/apps/notifications/models.py |  2 +-
 combo/apps/pwa/models.py           |  2 +-
 combo/apps/pwa/views.py            |  2 +-
 combo/apps/search/manager_views.py |  2 +-
 combo/data/models.py               |  2 +-
 combo/manager/views.py             |  4 +---
 combo/profile/__init__.py          |  2 +-
 combo/public/templatetags/combo.py |  2 +-
 combo/public/views.py              |  7 +++----
 combo/utils/requests_wrapper.py    |  6 ++----
 tests/test_assets.py               |  2 +-
 tests/test_cells.py                |  4 +---
 tests/test_dashboard.py            | 24 ++++++++++++------------
 tests/test_dataviz.py              | 24 ++++++++++++------------
 tests/test_lingo_cells.py          |  2 +-
 tests/test_lingo_payment.py        | 19 +++++++++----------
 tests/test_lingo_remote_regie.py   |  6 +++---
 tests/test_manager.py              | 11 +++++------
 tests/test_notification.py         |  1 -
 tests/test_pages.py                |  2 +-
 tests/test_public.py               |  2 +-
 tests/test_pwa.py                  |  8 ++++----
 tests/test_requests.py             | 14 +++++++-------
 tests/test_search.py               |  4 ++--
 35 files changed, 82 insertions(+), 95 deletions(-)

diff --git a/combo/apps/assets/api_views.py b/combo/apps/assets/api_views.py
index c440d058..f9aa3a71 100644
--- a/combo/apps/assets/api_views.py
+++ b/combo/apps/assets/api_views.py
@@ -52,7 +52,7 @@ class Set(GenericAPIView):
             return Response(response, status.HTTP_400_BAD_REQUEST)
         data = serializer.validated_data
 
-        asset, created = Asset.objects.get_or_create(key=key)
+        asset, dummy = Asset.objects.get_or_create(key=key)
         asset.asset = File(BytesIO(data['asset']['content']), name=data['asset'].get('filename'))
         asset.save()
         response = {'err': 0}
diff --git a/combo/apps/assets/models.py b/combo/apps/assets/models.py
index 2cec3e07..546d9ca8 100644
--- a/combo/apps/assets/models.py
+++ b/combo/apps/assets/models.py
@@ -53,7 +53,7 @@ class Asset(models.Model):
     @classmethod
     def load_serialized_object(cls, json_asset):
         json_asset['model'] = 'assets.asset'
-        asset, created = Asset.objects.get_or_create(key=json_asset['fields']['key'])
+        asset, dummy = Asset.objects.get_or_create(key=json_asset['fields']['key'])
         json_asset['pk'] = asset.id
         asset = next(serializers.deserialize('json', json.dumps([json_asset]), ignorenonexistent=True))
         asset.save()
diff --git a/combo/apps/assets/utils.py b/combo/apps/assets/utils.py
index b80bc648..90cb7b98 100644
--- a/combo/apps/assets/utils.py
+++ b/combo/apps/assets/utils.py
@@ -26,7 +26,7 @@ from .models import Asset
 
 def clean_assets_files():
     media_prefix = default_storage.path('')
-    for basedir, dirnames, filenames in os.walk(media_prefix):
+    for basedir, dummy, filenames in os.walk(media_prefix):
         for filename in filenames:
             os.remove('%s/%s' % (basedir, filename))
 
@@ -58,7 +58,7 @@ def untar_assets_files(tar, overwrite=False):
 
 def tar_assets_files(tar):
     media_prefix = default_storage.path('')
-    for basedir, dirnames, filenames in os.walk(media_prefix):
+    for basedir, dummy, filenames in os.walk(media_prefix):
         for filename in filenames:
             tar.add(os.path.join(basedir, filename), os.path.join(basedir, filename)[len(media_prefix) :])
     export = {'assets': Asset.export_all_for_json()}
diff --git a/combo/apps/assets/views.py b/combo/apps/assets/views.py
index 66d1e086..baa9bd0b 100644
--- a/combo/apps/assets/views.py
+++ b/combo/apps/assets/views.py
@@ -394,7 +394,7 @@ class AssetsExportSize(TemplateView):
         context = super().get_context_data(**kwargs)
         media_prefix = default_storage.path('')
         computed_size = 0
-        for basedir, dirnames, filenames in os.walk(media_prefix):
+        for basedir, dummy, filenames in os.walk(media_prefix):
             for filename in filenames:
                 computed_size += os.stat(os.path.join(basedir, filename)).st_size
         context['size'] = computed_size
diff --git a/combo/apps/calendar/utils.py b/combo/apps/calendar/utils.py
index a5ec2241..e8a19d05 100644
--- a/combo/apps/calendar/utils.py
+++ b/combo/apps/calendar/utils.py
@@ -67,7 +67,7 @@ def get_agendas():
 
 
 def get_chrono_events(agenda_reference, synchronous):
-    chrono_key, chrono_slug = agenda_reference.split(':')
+    dummy, chrono_slug = agenda_reference.split(':')
     chrono = get_chrono_service()
     response = requests.get(
         'api/agenda/%s/datetimes/' % chrono_slug,
diff --git a/combo/apps/dashboard/views.py b/combo/apps/dashboard/views.py
index 1e39793c..b1102d05 100644
--- a/combo/apps/dashboard/views.py
+++ b/combo/apps/dashboard/views.py
@@ -154,7 +154,6 @@ def dashboard_auto_tile(request, *args, **kwargs):
 
 
 def dashboard_reorder_tiles(request, *args, **kwargs):
-    dashboard = DashboardCell.objects.filter(page__snapshot__isnull=True)[0]
     new_order = request.GET['order'].split(',')
     tiles = {str(x.id): x for x in Tile.objects.filter(id__in=new_order)}
     for i, tile_id in enumerate(new_order):
diff --git a/combo/apps/dataviz/forms.py b/combo/apps/dataviz/forms.py
index fa9f09a5..e6f29f8e 100644
--- a/combo/apps/dataviz/forms.py
+++ b/combo/apps/dataviz/forms.py
@@ -35,7 +35,7 @@ class ChartForm(forms.ModelForm):
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
         available_charts = []
-        for site_key, site_dict in settings.KNOWN_SERVICES.get('bijoe').items():
+        for site_dict in settings.KNOWN_SERVICES.get('bijoe').values():
             result = requests.get(
                 '/visualization/json/',
                 remote_service=site_dict,
diff --git a/combo/apps/dataviz/utils.py b/combo/apps/dataviz/utils.py
index 90f3e7fa..be9760a7 100644
--- a/combo/apps/dataviz/utils.py
+++ b/combo/apps/dataviz/utils.py
@@ -1,6 +1,5 @@
 import django
 from django.conf import settings
-from django.utils import timezone
 
 from combo.utils import requests
 
@@ -12,7 +11,6 @@ def update_available_statistics():
         return
 
     results = []
-    start_update = timezone.now()
     for provider in settings.STATISTICS_PROVIDERS:
         if isinstance(provider, dict):
             url = provider['url']
diff --git a/combo/apps/dataviz/views.py b/combo/apps/dataviz/views.py
index af811b2a..ca44ab52 100644
--- a/combo/apps/dataviz/views.py
+++ b/combo/apps/dataviz/views.py
@@ -44,7 +44,7 @@ def dataviz_graph(request, *args, **kwargs):
             width=int(request.GET['width']) if request.GET.get('width') else None,
             height=int(request.GET['height']) if request.GET.get('height') else int(cell.height),
         )
-    except UnsupportedDataSet as e:
+    except UnsupportedDataSet:
         error_text = _('Unsupported dataset.')
     except HTTPError as e:
         if e.response.status_code == 404:
diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py
index be2b9f9d..40876d73 100644
--- a/combo/apps/lingo/models.py
+++ b/combo/apps/lingo/models.py
@@ -887,7 +887,7 @@ class Transaction(models.Model):
 
     def create_paid_invoice_basket_item(self, item_id, remote_item):
         subject = _('Invoice #%s') % remote_item.display_id
-        basket_item, created = BasketItem.objects.get_or_create(
+        basket_item, dummy = BasketItem.objects.get_or_create(
             remote_item_id=item_id,
             defaults=dict(
                 user=self.user,
diff --git a/combo/apps/maps/models.py b/combo/apps/maps/models.py
index 125eac5c..63106a63 100644
--- a/combo/apps/maps/models.py
+++ b/combo/apps/maps/models.py
@@ -190,7 +190,7 @@ class MapLayer(models.Model):
     @classmethod
     def load_serialized_object(cls, json_layer):
         json_layer['model'] = 'maps.maplayer'
-        layer, created = MapLayer.objects.get_or_create(slug=json_layer['fields']['slug'])
+        layer, dummy = MapLayer.objects.get_or_create(slug=json_layer['fields']['slug'])
         json_layer['pk'] = layer.id
         layer = next(serializers.deserialize('json', json.dumps([json_layer]), ignorenonexistent=True))
         layer.save()
diff --git a/combo/apps/notifications/models.py b/combo/apps/notifications/models.py
index d12abb23..21c92490 100644
--- a/combo/apps/notifications/models.py
+++ b/combo/apps/notifications/models.py
@@ -151,7 +151,7 @@ class Notification(models.Model):
                 raise ValueError('id must be convertible to unicode', e)
             if not re.match(cls.ID_RE, id):
                 raise ValueError('id must match regular expression %s' % cls.ID_RE)
-            notification, created = Notification.objects.update_or_create(
+            notification, dummy = Notification.objects.update_or_create(
                 user=user, external_id=id, defaults=defaults
             )
         else:
diff --git a/combo/apps/pwa/models.py b/combo/apps/pwa/models.py
index 5f2a7587..ff0c84dc 100644
--- a/combo/apps/pwa/models.py
+++ b/combo/apps/pwa/models.py
@@ -173,7 +173,7 @@ class PwaNavigationEntry(models.Model):
         json_entry['model'] = 'pwa.pwanavigationentry'
         # deserialize once to get link_page by natural key
         fake_entry = next(serializers.deserialize('json', json.dumps([json_entry]), ignorenonexistent=True))
-        entry, created = cls.objects.get_or_create(
+        entry, dummy = cls.objects.get_or_create(
             label=json_entry['fields']['label'],
             url=json_entry['fields']['url'],
             link_page=fake_entry.object.link_page,
diff --git a/combo/apps/pwa/views.py b/combo/apps/pwa/views.py
index a67d356d..375cd118 100644
--- a/combo/apps/pwa/views.py
+++ b/combo/apps/pwa/views.py
@@ -99,7 +99,7 @@ def subscribe_push(request, *args, **kwargs):
     if subscription_data is None:
         PushSubscription.objects.filter(user=request.user).delete()
     else:
-        subscription, created = PushSubscription.objects.get_or_create(
+        subscription, dummy = PushSubscription.objects.get_or_create(
             user=request.user, subscription_info=subscription_data
         )
         subscription.save()
diff --git a/combo/apps/search/manager_views.py b/combo/apps/search/manager_views.py
index 8f6372dd..e36ff029 100644
--- a/combo/apps/search/manager_views.py
+++ b/combo/apps/search/manager_views.py
@@ -150,7 +150,7 @@ def search_engines_order(request, page_pk, cell_reference):
         return HttpResponse(status=204)
 
     engines = []
-    for i, engine_slug in enumerate(cell._search_services['data']):
+    for engine_slug in cell._search_services['data']:
         try:
             new_order = int(request.GET.get('pos_' + str(engine_slug)))
         except TypeError:
diff --git a/combo/data/models.py b/combo/data/models.py
index 21381b82..d67b03a5 100644
--- a/combo/data/models.py
+++ b/combo/data/models.py
@@ -114,7 +114,7 @@ def format_sub_slug(sub_slug):
 
 
 def compile_sub_slug(sub_slug):
-    sub_slug, mapping = format_sub_slug(sub_slug)
+    sub_slug = format_sub_slug(sub_slug)[0]
     # will raise re.error if wrong regexp
     re.compile(sub_slug)
 
diff --git a/combo/manager/views.py b/combo/manager/views.py
index 6c029b49..851b40b6 100644
--- a/combo/manager/views.py
+++ b/combo/manager/views.py
@@ -341,10 +341,8 @@ class PageView(DetailView):
 
         cells = CellBase.get_cells(page=self.object, prefetch_validity_info=True)
         self.object.prefetched_cells = cells
-        template = self.object.template_name
         placeholders = []
         optional_placeholders = []
-        combo_template = settings.COMBO_PUBLIC_TEMPLATES.get(template)
 
         for placeholder in self.object.get_placeholders(request=self.request, traverse_cells=True):
             placeholder_dict = {
@@ -748,7 +746,7 @@ def menu_json(request):
     slug = 'portal'
     if getattr(settings, 'KNOWN_SERVICES') and 'combo' in settings.KNOWN_SERVICES:
         # switch to custom slug if the site is the portal agent.
-        for service_slug, service in settings.KNOWN_SERVICES['combo'].items():
+        for service in settings.KNOWN_SERVICES['combo'].values():
             if service.get('is-portal-agent') and not service.get('secret'):
                 slug = 'portal-agent'
                 break
diff --git a/combo/profile/__init__.py b/combo/profile/__init__.py
index 1f546a8d..fe0f1b28 100644
--- a/combo/profile/__init__.py
+++ b/combo/profile/__init__.py
@@ -64,7 +64,7 @@ class AppConfig(django.apps.AppConfig):
         user_page_base_url = user_page.get_online_url()
 
         # return entry using first(&only) authentic (if it exists)
-        for key, service in settings.KNOWN_SERVICES.get('authentic', {}).items():
+        for service in settings.KNOWN_SERVICES.get('authentic', {}).values():
             return {
                 'users': {
                     'url': service['url'] + 'api/users/?q=%(q)s',
diff --git a/combo/public/templatetags/combo.py b/combo/public/templatetags/combo.py
index 4da44762..faf24c9a 100644
--- a/combo/public/templatetags/combo.py
+++ b/combo/public/templatetags/combo.py
@@ -166,7 +166,7 @@ def render_cell(context, cell):
 @register.tag
 def skeleton_extra_placeholder(parser, token):
     try:
-        tag_name, placeholder_name = token.split_contents()
+        dummy, placeholder_name = token.split_contents()
     except ValueError:
         raise template.TemplateSyntaxError("%r tag requires exactly one argument" % token.contents.split()[0])
 
diff --git a/combo/public/views.py b/combo/public/views.py
index 3c1e3ced..193ee672 100644
--- a/combo/public/views.py
+++ b/combo/public/views.py
@@ -232,7 +232,7 @@ def mark_duplicated_slugs(cells):
         if cell.slug not in cell_by_slugs:
             cell_by_slugs[cell.slug] = []
         cell_by_slugs[cell.slug].append(cell)
-    for slug, slug_cells in cell_by_slugs.items():
+    for slug_cells in cell_by_slugs.values():
         for cell in slug_cells:
             cell.use_slug_as_id = bool(len(slug_cells) == 1)
 
@@ -343,7 +343,7 @@ def skeleton(request):
         if cell.slug not in cell_by_slugs:
             cell_by_slugs[cell.slug] = []
         cell_by_slugs[cell.slug].append(cell)
-    for slug, slug_cells in cell_by_slugs.items():
+    for slug_cells in cell_by_slugs.values():
         for cell in slug_cells:
             cell.use_slug_as_id = bool(len(slug_cells) == 1)
 
@@ -376,7 +376,6 @@ class StyleDemoPage:
         self.page = Page(public=False, title=_('Style Demo'))
         self.page.template_name = self.template_name
         self.page.save()
-        combo_template = settings.COMBO_PUBLIC_TEMPLATES[self.page.template_name]
         for i, placeholder in enumerate(self.page.get_placeholders(request=self.request)):
             cell = TextCell(page=self.page, placeholder=placeholder.key, order=0)
             if placeholder.key == 'footer':
@@ -466,7 +465,7 @@ def page(request):
         and settings.COMBO_INITIAL_LOGIN_PAGE_PATH
         and (request.user and not request.user.is_anonymous)
     ):
-        profile, created = Profile.objects.get_or_create(user=request.user)
+        profile, dummy = Profile.objects.get_or_create(user=request.user)
         if not profile.initial_login_view_timestamp:
             # first connection of user, record that and redirect to welcome URL
             profile.initial_login_view_timestamp = timezone.now()
diff --git a/combo/utils/requests_wrapper.py b/combo/utils/requests_wrapper.py
index ce064ab5..c7517709 100644
--- a/combo/utils/requests_wrapper.py
+++ b/combo/utils/requests_wrapper.py
@@ -64,9 +64,7 @@ class Requests(RequestsSession):
             for services in settings.KNOWN_SERVICES.values():
                 for service in services.values():
                     remote_url = service.get('url')
-                    remote_scheme, remote_netloc, r_path, r_params, r_query, r_fragment = urlparse.urlparse(
-                        remote_url
-                    )
+                    remote_scheme, remote_netloc, dummy, dummy, dummy, dummy = urlparse.urlparse(remote_url)
                     if remote_scheme == scheme and remote_netloc == netloc:
                         remote_service = service
                         break
@@ -105,7 +103,7 @@ class Requests(RequestsSession):
                 query_params['orig'] = remote_service.get('orig')
 
             remote_service_base_url = remote_service.get('url')
-            scheme, netloc, old_path, params, old_query, fragment = urlparse.urlparse(remote_service_base_url)
+            scheme, netloc, dummy, params, old_query, fragment = urlparse.urlparse(remote_service_base_url)
 
             query = urlencode(query_params)
             if '?' in url:
diff --git a/tests/test_assets.py b/tests/test_assets.py
index 7484ba33..711b68d0 100644
--- a/tests/test_assets.py
+++ b/tests/test_assets.py
@@ -30,7 +30,7 @@ def some_assets():
 def count_asset_files():
     nb_assets = 0
     media_prefix = default_storage.path('')
-    for basedir, dirnames, filenames in os.walk(media_prefix):
+    for dummy, dummy, filenames in os.walk(media_prefix):
         nb_assets += len(filenames)
     return nb_assets
 
diff --git a/tests/test_cells.py b/tests/test_cells.py
index 68789771..6b8c5f66 100644
--- a/tests/test_cells.py
+++ b/tests/test_cells.py
@@ -822,7 +822,7 @@ def test_config_json_cell_with_param_in_url(app):
                 'combo-public-ajax-page-cell',
                 kwargs={'page_pk': page.id, 'cell_reference': cell.get_reference()},
             )
-            resp = app.get(url)
+            app.get(url)
             assert requests_get.call_count == 1
             assert requests_get.call_args[0][0] == 'http://foo?var=plop'
             assert requests_get.call_args[-1]['log_errors'] == False
@@ -1280,8 +1280,6 @@ def test_config_json_invalid_key_cell():
     page = Page(title='example page', slug='example-page')
     page.save()
 
-    request = RequestFactory().get('/')
-
     with override_settings(JSON_CELL_TYPES={'foobar': {'name': 'Foobar', 'url': 'http://test/'}}):
         cell = ConfigJsonCell()
         cell.key = 'foobar'
diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py
index e90a201d..c57da7c4 100644
--- a/tests/test_dashboard.py
+++ b/tests/test_dashboard.py
@@ -66,13 +66,13 @@ def test_add_to_dashboard(app, site):
 def test_add_to_dashboard_order(app, site):
     test_add_to_dashboard(app, site)
     cell = TextCell.objects.get(order=101)
-    resp = app.get(reverse('combo-dashboard-add-tile', kwargs={'cell_reference': cell.get_reference()}))
+    app.get(reverse('combo-dashboard-add-tile', kwargs={'cell_reference': cell.get_reference()}))
     assert Tile.objects.count() == 2
     assert Tile.objects.all()[0].cell.text == 'hello world (100)'
     assert Tile.objects.all()[1].cell.text == 'hello world (101)'
 
     cell = TextCell.objects.get(order=102)
-    resp = app.get(reverse('combo-dashboard-add-tile', kwargs={'cell_reference': cell.get_reference()}))
+    app.get(reverse('combo-dashboard-add-tile', kwargs={'cell_reference': cell.get_reference()}))
     assert Tile.objects.count() == 3
     assert Tile.objects.all()[0].cell.text == 'hello world (100)'
     assert Tile.objects.all()[1].cell.text == 'hello world (101)'
@@ -80,7 +80,7 @@ def test_add_to_dashboard_order(app, site):
 
     with override_settings(COMBO_DASHBOARD_NEW_TILE_POSITION='first'):
         cell = TextCell.objects.get(order=103)
-        resp = app.get(reverse('combo-dashboard-add-tile', kwargs={'cell_reference': cell.get_reference()}))
+        app.get(reverse('combo-dashboard-add-tile', kwargs={'cell_reference': cell.get_reference()}))
         assert Tile.objects.count() == 4
         assert Tile.objects.all()[0].cell.text == 'hello world (103)'
         assert Tile.objects.all()[1].cell.text == 'hello world (100)'
@@ -112,7 +112,7 @@ def test_ajax_render(app, site):
     app.reset()  # logout
     tile = Tile.objects.all()[0]
     page = Page.objects.get(slug='two')
-    resp = app.get(
+    app.get(
         reverse(
             'combo-public-ajax-page-cell',
             kwargs={'page_pk': page.id, 'cell_reference': tile.cell.get_reference()},
@@ -121,7 +121,7 @@ def test_ajax_render(app, site):
     )
 
     app = login(app)
-    resp = app.get(
+    app.get(
         reverse(
             'combo-public-ajax-page-cell',
             kwargs={'page_pk': page.id, 'cell_reference': tile.cell.get_reference()},
@@ -129,9 +129,9 @@ def test_ajax_render(app, site):
         status=200,
     )
 
-    user = User.objects.create_user('plop', email=None, password='plop')
+    User.objects.create_user('plop', email=None, password='plop')
     app = login(app, username='plop', password='plop')
-    resp = app.get(
+    app.get(
         reverse(
             'combo-public-ajax-page-cell',
             kwargs={'page_pk': page.id, 'cell_reference': tile.cell.get_reference()},
@@ -144,13 +144,13 @@ def test_remove_from_dashboard(app, site):
     test_add_to_dashboard(app, site)
     app.reset()  # logout
     tile = Tile.objects.all()[0]
-    resp = app.get(
+    app.get(
         reverse('combo-dashboard-remove-tile', kwargs={'cell_reference': tile.cell.get_reference()}),
         status=403,
     )
 
     app = login(app)
-    resp = app.get(
+    app.get(
         reverse('combo-dashboard-remove-tile', kwargs={'cell_reference': tile.cell.get_reference()}),
         status=302,
     )
@@ -180,7 +180,7 @@ def test_reorder_dashboard(app, site):
     # add cells to dashboard
     app = login(app)
     for i in range(103, 108):
-        resp = app.get(
+        app.get(
             reverse(
                 'combo-dashboard-add-tile',
                 kwargs={'cell_reference': TextCell.objects.get(order=i).get_reference()},
@@ -192,14 +192,14 @@ def test_reorder_dashboard(app, site):
     app.reset()  # logout
     tiles = Tile.objects.filter(user=user).order_by('?')
     new_order = ','.join([str(x.id) for x in tiles])
-    resp = app.get(
+    app.get(
         reverse('combo-dashboard-reorder-tiles', kwargs={'dashboard_id': dashboard.id}),
         params={'order': new_order},
         status=403,
     )
 
     app = login(app)
-    resp = app.get(
+    app.get(
         reverse('combo-dashboard-reorder-tiles', kwargs={'dashboard_id': dashboard.id}),
         params={'order': new_order},
     )
diff --git a/tests/test_dataviz.py b/tests/test_dataviz.py
index 31237e88..06b230d1 100644
--- a/tests/test_dataviz.py
+++ b/tests/test_dataviz.py
@@ -1377,14 +1377,14 @@ def test_chartng_cell_new_api_filter_params(new_api_statistics, nocache, freezer
     cell.statistic = Statistic.objects.get(slug='one-serie')
     cell.save()
 
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][0]
     assert 'time_interval=' not in request.url
     assert 'ou=' not in request.url
 
     cell.filter_params = {'time_interval': 'month', 'ou': 'default'}
     cell.save()
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][1]
     assert 'time_interval=month' in request.url
     assert 'ou=default' in request.url
@@ -1392,7 +1392,7 @@ def test_chartng_cell_new_api_filter_params(new_api_statistics, nocache, freezer
     freezer.move_to(date)
     cell.time_range = 'previous-year'
     cell.save()
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][2]
     assert 'time_interval=month' in request.url
     assert 'ou=default' in request.url
@@ -1400,38 +1400,38 @@ def test_chartng_cell_new_api_filter_params(new_api_statistics, nocache, freezer
 
     cell.time_range = 'current-week'
     cell.save()
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][-1]
     assert 'start=2020-03-02' in request.url and 'end=2020-03-09' in request.url
 
     cell.time_range = 'previous-week'
     cell.save()
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][-1]
     assert 'start=2020-02-24' in request.url and 'end=2020-03-02' in request.url
 
     cell.time_range = 'next-week'
     cell.save()
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][-1]
     assert 'start=2020-03-09' in request.url and 'end=2020-03-16' in request.url
 
     cell.time_range = 'range'
     cell.save()
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][-1]
     assert 'start' not in urllib.parse.parse_qs(urllib.parse.urlparse(request.url).query)
     assert 'end' not in urllib.parse.parse_qs(urllib.parse.urlparse(request.url).query)
 
     cell.time_range_start = '2020-10-01'
     cell.save()
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][-1]
     assert 'start=2020-10-01' in request.url
 
     cell.time_range_end = '2020-11-03'
     cell.save()
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][-1]
     assert 'start=2020-10-01' in request.url and 'end=2020-11-03' in request.url
 
@@ -1448,20 +1448,20 @@ def test_chartng_cell_new_api_filter_params_month(new_api_statistics, nocache, f
     cell.save()
 
     freezer.move_to('2021-01-02')
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][0]
     assert 'start=2021-01-01' in request.url and 'end=2021-02-01' in request.url
 
     cell.time_range = 'previous-month'
     cell.save()
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][1]
     assert 'start=2020-12-01' in request.url and 'end=2021-01-01' in request.url
 
     freezer.move_to('2021-11-02')
     cell.time_range = 'next-month'
     cell.save()
-    chart = cell.get_chart()
+    cell.get_chart()
     request = new_api_mock.call['requests'][2]
     assert 'start=2021-12-01' in request.url and 'end=2022-01-01' in request.url
 
diff --git a/tests/test_lingo_cells.py b/tests/test_lingo_cells.py
index 7e1a9467..0a43ac50 100644
--- a/tests/test_lingo_cells.py
+++ b/tests/test_lingo_cells.py
@@ -201,7 +201,7 @@ def test_basket_link_cell_in_skeleton(app, regie, user):
     page.save()
     cell = LingoBasketLinkCell(page=page, placeholder='content', order=0)
     cell.save()
-    resp = app.get('/__skeleton__/?source=%s' % quote('http://example.net/foo/bar'))
+    app.get('/__skeleton__/?source=%s' % quote('http://example.net/foo/bar'))
 
 
 def test_tipi_cell():
diff --git a/tests/test_lingo_payment.py b/tests/test_lingo_payment.py
index 5e8b1389..3614c7d0 100644
--- a/tests/test_lingo_payment.py
+++ b/tests/test_lingo_payment.py
@@ -242,7 +242,7 @@ def test_successfull_items_payment(app, basket_page, regie, user, with_payment_b
         '/lingo/return-payment-backend/%s/' % regie.payment_backend.id
     )
     # simulate successful call to callback URL
-    with mock.patch('combo.utils.requests_wrapper.RequestsSession.request') as request:
+    with mock.patch('combo.utils.requests_wrapper.RequestsSession.request'):
         resp = app.get(get_url(with_payment_backend, 'lingo-callback', regie), params=args)
     assert resp.status_code == 200
     # simulate successful return URL
@@ -343,7 +343,6 @@ def test_add_amount_to_basket(app, key, regie, user_name_id):
     url = '%s?NameId=%s&orig=wcs' % (reverse('api-add-basket-item'), user_name_id)
     url = sign_url(url, settings.LINGO_API_SIGN_KEY)
     resp = app.post_json(url, params=data)
-    item = BasketItem.objects.get(amount=Decimal('22.23'))
     assert resp.status_code == 200
     response = json.loads(resp.text)
     assert response['result'] == 'success'
@@ -810,7 +809,7 @@ def test_cancel_basket_item_from_cell(app, key, regie, user_name_id):
 def test_payment_callback(app, basket_page, regie, user, with_payment_backend):
     page = Page(title='xxx', slug='index', template_name='standard')
     page.save()
-    item = BasketItem.objects.create(
+    BasketItem.objects.create(
         user=user, regie=regie, subject='test_item', amount='10.5', source_url='http://example.org/testitem/'
     )
     resp = login(app).get(basket_page.get_online_url())
@@ -832,7 +831,7 @@ def test_payment_callback(app, basket_page, regie, user, with_payment_backend):
     assert get_resp.status_code == 200
     assert Transaction.objects.get(order_id=transaction_id).status == 3
 
-    item = BasketItem.objects.create(
+    BasketItem.objects.create(
         user=user, regie=regie, subject='test_item', amount='11.5', source_url='http://example.org/testitem/'
     )
     resp = login(app).get(basket_page.get_online_url())
@@ -861,7 +860,7 @@ def test_payment_callback(app, basket_page, regie, user, with_payment_backend):
 
 @pytest.mark.parametrize('with_payment_backend', [False, True])
 def test_payment_callback_no_regie(app, basket_page, regie, user, with_payment_backend):
-    item = BasketItem.objects.create(
+    BasketItem.objects.create(
         user=user, regie=regie, subject='test_item', amount='10.5', source_url='http://example.org/testitem/'
     )
     resp = login(app).get(basket_page.get_online_url())
@@ -883,7 +882,7 @@ def test_payment_callback_no_regie(app, basket_page, regie, user, with_payment_b
     assert get_resp.status_code == 200
     assert Transaction.objects.get(order_id=transaction_id).status == 3
 
-    item = BasketItem.objects.create(
+    BasketItem.objects.create(
         user=user, regie=regie, subject='test_item', amount='11.5', source_url='http://example.org/testitem/'
     )
     resp = login(app).get(basket_page.get_online_url())
@@ -901,7 +900,7 @@ def test_payment_callback_no_regie(app, basket_page, regie, user, with_payment_b
 def test_payment_return_without_query_string(app, basket_page, regie, user, with_payment_backend):
     page = Page(title='xxx', slug='index', template_name='standard')
     page.save()
-    item = BasketItem.objects.create(
+    BasketItem.objects.create(
         user=user, regie=regie, subject='test_item', amount='10.5', source_url='http://example.org/testitem/'
     )
     resp = login(app).get(basket_page.get_online_url())
@@ -916,7 +915,7 @@ def test_payment_return_without_query_string(app, basket_page, regie, user, with
 
     # payment status is obtained through callback
     callback_url = get_url(with_payment_backend, 'lingo-callback', regie)
-    with mock.patch('combo.utils.requests_wrapper.RequestsSession.request') as request:
+    with mock.patch('combo.utils.requests_wrapper.RequestsSession.request'):
         get_resp = app.get(callback_url, params=data)
     transaction = Transaction.objects.get(order_id=transaction_id)
     assert transaction.status == 3
@@ -988,7 +987,7 @@ def test_payment_callback_waiting(app, basket_page, regie, user, with_payment_ba
 
 @pytest.mark.parametrize('with_payment_backend', [False, True])
 def test_payment_no_callback_just_return(caplog, app, basket_page, regie, user, with_payment_backend):
-    item = BasketItem.objects.create(
+    BasketItem.objects.create(
         user=user, regie=regie, subject='test_item', amount='10.5', source_url='http://example.org/testitem/'
     )
     resp = login(app).get(basket_page.get_online_url())
@@ -1615,7 +1614,7 @@ def test_transaction_status_api(app, regie, user):
 
 
 def test_request_payment_exception(app, basket_page, regie, user):
-    item = BasketItem.objects.create(
+    BasketItem.objects.create(
         user=user, regie=regie, subject='test_item', amount='10.5', source_url='http://example.org/testitem/'
     )
 
diff --git a/tests/test_lingo_remote_regie.py b/tests/test_lingo_remote_regie.py
index 9f7cf524..41598329 100644
--- a/tests/test_lingo_remote_regie.py
+++ b/tests/test_lingo_remote_regie.py
@@ -156,7 +156,7 @@ def test_remote_regie_active_invoices_cell(mock_send, remote_regie):
     # check if regie webservice has been correctly called
     assert mock_send.call_args[0][0].method == 'GET'
     url = mock_send.call_args[0][0].url
-    scheme, netloc, path, params, querystring, fragment = urlparse.urlparse(url)
+    scheme, netloc, path, dummy, querystring, dummy = urlparse.urlparse(url)
     assert scheme == 'http'
     assert netloc == 'example.org'
     assert path == '/regie/invoices/'
@@ -285,7 +285,7 @@ def test_remote_regie_past_invoices_cell(mock_send, remote_regie):
     # check if regie webservice has been correctly called
     assert mock_send.call_args[0][0].method == 'GET'
     url = mock_send.call_args[0][0].url
-    scheme, netloc, path, params, querystring, fragment = urlparse.urlparse(url)
+    scheme, netloc, path, dummy, querystring, dummy = urlparse.urlparse(url)
     assert scheme == 'http'
     assert netloc == 'example.org'
     assert path == '/regie/invoices/history/'
@@ -530,7 +530,7 @@ def test_wrong_crypted_item(mock_get, remote_regie, app):
     mock_json = mock.Mock()
     mock_json.json.return_value = {'err': 0, 'data': INVOICES[0]}
     mock_get.return_value = mock_json
-    resp = app.get('/lingo/item/%s/%s/' % (remote_regie.id, 'zrzer854sfaear45e6rzerzerzef'), status=404)
+    app.get('/lingo/item/%s/%s/' % (remote_regie.id, 'zrzer854sfaear45e6rzerzerzef'), status=404)
 
 
 @mock.patch('combo.apps.lingo.models.requests.get')
diff --git a/tests/test_manager.py b/tests/test_manager.py
index 9f7374cf..446f0a94 100644
--- a/tests/test_manager.py
+++ b/tests/test_manager.py
@@ -1403,7 +1403,7 @@ def test_edit_cell_order(app, admin_user):
 
     params = []
     new_order = [2, 3, 1, 4, 5]
-    for i, (cell, new_pos) in enumerate(zip(cells, new_order)):
+    for i, (cell, dummy) in enumerate(zip(cells, new_order)):
         params.append(('ph_data_textcell-%s' % cell.id, 'content'))  # no placeholder change
         params.append(('pos_data_textcell-%s' % cell.id, str(new_order[i])))
 
@@ -1659,7 +1659,7 @@ def test_asset_management_anchor(app, admin_user):
     resp = app.get('/manage/assets/')
     assert 'have any asset yet.' in resp.text
 
-    for i in range(25):
+    for dummy in range(25):
         filepath = os.path.join(settings.CKEDITOR_UPLOAD_PATH, 'cc.png')
         pix = b'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQAAAAA3bvkkAAAACklEQVQI12NoAAAAggCB3UNq9AAAAABJRU5ErkJggg=='
         default_storage.save(filepath, BytesIO(base64.decodebytes(pix)))
@@ -1751,7 +1751,7 @@ def test_assets_browse(app, admin_user):
     assert 'CKEditorFuncNum=0' in resp.request.url
     assert resp.text.count('<tr class="asset') == 2
 
-    for i in range(25):
+    for dummy in range(25):
         filepath = os.path.join(settings.CKEDITOR_UPLOAD_PATH, 'cc.png')
         pix = b'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQAAAAA3bvkkAAAACklEQVQI12NoAAAAggCB3UNq9AAAAABJRU5ErkJggg=='
         default_storage.save(filepath, BytesIO(base64.decodebytes(pix)))
@@ -2161,8 +2161,7 @@ def test_page_discover_placeholder_with_error_cells(app, admin_user):
 
     app = login(app)
 
-    with mock.patch('combo.utils.requests.get') as requests_get:
-        data = {'data': [{'url': 'xxx', 'text': 'xxx'}]}
+    with mock.patch('combo.utils.requests.get'):
         with pytest.raises(TemplateSyntaxError):
             cell.render({})
 
@@ -2473,7 +2472,7 @@ def test_edit_link_list_order(app, admin_user):
 
     params = []
     new_order = [2, 3, 1, 4, 5]
-    for i, (item, new_pos) in enumerate(zip(items, new_order)):
+    for item, new_pos in zip(items, new_order):
         params.append(('pos_%s' % item.pk, str(new_pos)))
 
     app = login(app)
diff --git a/tests/test_notification.py b/tests/test_notification.py
index 0ebf6a53..44b7bf58 100644
--- a/tests/test_notification.py
+++ b/tests/test_notification.py
@@ -289,7 +289,6 @@ def test_notification_id_and_origin(john_doe):
 @mock.patch('combo.utils.requests_wrapper.RequestsSession.request')
 def test_notify_remote_items(mock_get, app, john_doe, jane_doe, regie, monkeypatch, freezer):
     freezer.move_to('2016-01-02')
-    datetime_format = '%Y-%m-%dT%H:%M:%S'
     invoice_now = now()
     invoice_now = freezer()
     FAKE_PENDING_INVOICES = {
diff --git a/tests/test_pages.py b/tests/test_pages.py
index 99d4fe53..ad1b4f97 100644
--- a/tests/test_pages.py
+++ b/tests/test_pages.py
@@ -462,7 +462,7 @@ def test_get_descendants_and_me():
         page.parent_id = parent_id
         page.save()
         add_pages.num += 1
-        for m in range(0, depth + 1):
+        for dummy in range(0, depth + 1):
             add_pages(depth + 1, page.id)
 
     add_pages.num = 1
diff --git a/tests/test_public.py b/tests/test_public.py
index 6b034daf..9eaa11ef 100644
--- a/tests/test_public.py
+++ b/tests/test_public.py
@@ -282,7 +282,7 @@ def test_page_private_logged_in(app, admin_user):
     page = Page(title='Home', slug='index', template_name='standard', public=False)
     page.save()
     app = login(app)
-    resp = app.get('/', status=200)
+    app.get('/', status=200)
 
 
 def test_page_skeleton(app):
diff --git a/tests/test_pwa.py b/tests/test_pwa.py
index 7cdec80b..3adf0832 100644
--- a/tests/test_pwa.py
+++ b/tests/test_pwa.py
@@ -79,13 +79,13 @@ def test_webpush_notification(app, john_doe):
     pwa_settings.push_notifications = False
     pwa_settings.save()
     with mock.patch('pywebpush.webpush') as webpush:
-        notification = Notification.notify(john_doe, 'test', body='hello world')
+        Notification.notify(john_doe, 'test', body='hello world')
         assert webpush.call_count == 0
 
     pwa_settings.push_notifications = True
     pwa_settings.save()
     with mock.patch('pywebpush.webpush') as webpush:
-        notification = Notification.notify(john_doe, 'test', body='hello world')
+        Notification.notify(john_doe, 'test', body='hello world')
         assert webpush.call_count == 1
         assert webpush.call_args[1]['subscription_info'] == {'sample': 'content'}
 
@@ -96,7 +96,7 @@ def test_webpush_notification(app, john_doe):
         PWA_VAPID_CLAIMS={'sub': 'mailto:admin@entrouvert.com'},
     ):
         with mock.patch('pywebpush.webpush') as webpush:
-            notification = Notification.notify(john_doe, 'test', body='hello world')
+            Notification.notify(john_doe, 'test', body='hello world')
             assert webpush.call_count == 1
             assert webpush.call_args[1]['subscription_info'] == {'sample': 'content'}
             assert webpush.call_args[1]['vapid_private_key'] == settings.PWA_VAPID_PRIVATE_KEY
@@ -271,7 +271,7 @@ def test_pwa_application_icon(app, admin_user):
         assert len(resp.json['icons']) == 5
 
         # make sure largest icon is referenced in service worker
-        resp2 = app.get('/service-worker.js', status=200)
+        app.get('/service-worker.js', status=200)
         assert resp.json['icons'][-1]['src'].split('/')[-1] in resp.text
 
 
diff --git a/tests/test_requests.py b/tests/test_requests.py
index 9155bcfa..7561c559 100644
--- a/tests/test_requests.py
+++ b/tests/test_requests.py
@@ -32,7 +32,7 @@ def test_sign():
         requests.get('/foo/bar/', remote_service=remote_service)
         url = send.call_args[0][0].url
         assert url.startswith('http://example.org/foo/bar/?')
-        scheme, netloc, path, params, querystring, fragment = urlparse.urlparse(url)
+        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['orig'][0] == 'myself'
         assert query['email'][0] == ''
@@ -42,7 +42,7 @@ def test_sign():
         requests.get('/foo/bar/', remote_service=remote_service, without_user=True)
         url = send.call_args[0][0].url
         assert url.startswith('http://example.org/foo/bar/?')
-        scheme, netloc, path, params, querystring, fragment = urlparse.urlparse(url)
+        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['orig'][0] == 'myself'
         assert 'email' not in query
@@ -55,7 +55,7 @@ def test_auto_sign():
         requests.get('http://example.org/foo/bar/', remote_service='auto')
         url = send.call_args[0][0].url
         assert url.startswith('http://example.org/foo/bar/?')
-        scheme, netloc, path, params, querystring, fragment = urlparse.urlparse(url)
+        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['orig'][0] == 'combo'
         assert check_query(querystring, 'combo') == True
@@ -73,7 +73,7 @@ def test_sign_user():
         requests.get('/foo/bar/', remote_service=remote_service, user=user)
         url = send.call_args[0][0].url
         assert url.startswith('http://example.org/foo/bar/?')
-        scheme, netloc, path, params, querystring, fragment = urlparse.urlparse(url)
+        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['NameID'][0] == 'r2d2'
         assert 'email' not in query
@@ -83,7 +83,7 @@ def test_sign_user():
         requests.get('/foo/bar/', remote_service=remote_service, user=user, federation_key='email')
         url = send.call_args[0][0].url
         assert url.startswith('http://example.org/foo/bar/?')
-        scheme, netloc, path, params, querystring, fragment = urlparse.urlparse(url)
+        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['email'][0] == 'foo@example.net'
         assert 'NameID' not in query
@@ -95,7 +95,7 @@ def test_sign_user():
         requests.get('/foo/bar/', remote_service=remote_service, user=user)
         url = send.call_args[0][0].url
         assert url.startswith('http://example.org/foo/bar/?')
-        scheme, netloc, path, params, querystring, fragment = urlparse.urlparse(url)
+        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert 'NameID' not in query
         assert query['email'][0] == 'foo@example.net'
@@ -112,7 +112,7 @@ def test_sign_anonymous_user():
         requests.get('/foo/bar/', remote_service=remote_service, user=user)
         url = send.call_args[0][0].url
         assert url.startswith('http://example.org/foo/bar/?')
-        scheme, netloc, path, params, querystring, fragment = urlparse.urlparse(url)
+        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['NameID'][0] == ''
         assert query['email'][0] == ''
diff --git a/tests/test_search.py b/tests/test_search.py
index 51430a21..8fead4e7 100644
--- a/tests/test_search.py
+++ b/tests/test_search.py
@@ -243,7 +243,7 @@ def test_search_global_context(app):
         with mock.patch('combo.utils.requests.get') as requests_get:
             data = {'data': []}
             requests_get.return_value = mock.Mock(json=lambda: data, status_code=200)
-            resp = app.get(url)
+            app.get(url)
             assert requests_get.call_args[0][0] == 'http://www.example.net/search/foo/'
 
 
@@ -800,7 +800,7 @@ def test_manager_search_cell_order(settings, app, admin_user):
 
     params = []
     new_order = [2, 3, 1]
-    for i, (service_slug, new_pos) in enumerate(zip(cell._search_services['data'], new_order)):
+    for service_slug, new_pos in zip(cell._search_services['data'], new_order):
         params.append(('pos_%s' % service_slug, str(new_pos)))
 
     app = login(app)
-- 
2.30.2

