From 9ff97492dcfffa2c8116bc53b7fbea8e42d4a65a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= <zebuline@entrouvert.com>
Date: Fri, 9 Jul 2021 15:41:40 +0200
Subject: [PATCH 04/23] misc: fix unused-variable pylint error (#55505)

---
 .../migrations/0017_timeperiod_desk.py        |  4 +-
 chrono/agendas/migrations/0018_event_desk.py  |  2 +-
 ...iodexceptionsource_unique_settings_slug.py |  1 -
 chrono/agendas/models.py                      |  4 +-
 chrono/api/views.py                           |  2 +-
 chrono/manager/views.py                       |  6 +--
 chrono/utils/requests_wrapper.py              |  6 +--
 tests/api/conftest.py                         |  2 +-
 tests/api/test_all.py                         |  4 +-
 tests/api/test_booking.py                     |  2 +-
 tests/api/test_datetimes.py                   |  6 +--
 tests/api/test_fillslot.py                    |  8 ++--
 tests/manager/test_all.py                     | 16 +++----
 tests/manager/test_event.py                   |  6 +--
 tests/test_agendas.py                         | 42 +++++++++----------
 tests/test_import_export.py                   |  2 +-
 tests/test_misc.py                            |  6 +--
 tests/test_requests.py                        | 14 +++----
 18 files changed, 64 insertions(+), 69 deletions(-)

diff --git a/chrono/agendas/migrations/0017_timeperiod_desk.py b/chrono/agendas/migrations/0017_timeperiod_desk.py
index eac0dc0..d76803e 100644
--- a/chrono/agendas/migrations/0017_timeperiod_desk.py
+++ b/chrono/agendas/migrations/0017_timeperiod_desk.py
@@ -8,9 +8,7 @@ def set_timeperiod_desk(apps, schema_editor):
     TimePeriod = apps.get_model('agendas', 'TimePeriod')
     Desk = apps.get_model('agendas', 'Desk')
     for time_period in TimePeriod.objects.all():
-        desk, created = Desk.objects.get_or_create(
-            label='Guichet 1', slug='guichet-1', agenda=time_period.agenda
-        )
+        desk, _ = Desk.objects.get_or_create(label='Guichet 1', slug='guichet-1', agenda=time_period.agenda)
         time_period.desk = desk
         time_period.save()
 
diff --git a/chrono/agendas/migrations/0018_event_desk.py b/chrono/agendas/migrations/0018_event_desk.py
index 86a9d77..4f457de 100644
--- a/chrono/agendas/migrations/0018_event_desk.py
+++ b/chrono/agendas/migrations/0018_event_desk.py
@@ -11,7 +11,7 @@ def set_event_desk(apps, schema_editor):
         if not event.agenda.kind == 'meetings':
             continue
 
-        desk, created = Desk.objects.get_or_create(label='Guichet 1', slug='guichet-1', agenda=event.agenda)
+        desk, _ = Desk.objects.get_or_create(label='Guichet 1', slug='guichet-1', agenda=event.agenda)
         event.desk = desk
         event.save()
 
diff --git a/chrono/agendas/migrations/0066_timeperiodexceptionsource_unique_settings_slug.py b/chrono/agendas/migrations/0066_timeperiodexceptionsource_unique_settings_slug.py
index f8a92fc..18d216d 100644
--- a/chrono/agendas/migrations/0066_timeperiodexceptionsource_unique_settings_slug.py
+++ b/chrono/agendas/migrations/0066_timeperiodexceptionsource_unique_settings_slug.py
@@ -15,7 +15,6 @@ def remove_broken_exceptions(apps, schema_editor):
 
 def remove_duplicate_sources(apps, schema_editor):
     Desk = apps.get_model('agendas', 'Desk')
-    TimePeriodExceptionSource = apps.get_model('agendas', 'TimePeriodExceptionSource')
     for desk in Desk.objects.all():
         duplicate_source_slugs = (
             desk.timeperiodexceptionsource_set.values('settings_slug')
diff --git a/chrono/agendas/models.py b/chrono/agendas/models.py
index b21459a..a8e84fa 100644
--- a/chrono/agendas/models.py
+++ b/chrono/agendas/models.py
@@ -140,7 +140,7 @@ def event_template_validator(value):
         duration=1,
     )
     try:
-        event_text = Template(value).render(Context({'event': example_event}))
+        Template(value).render(Context({'event': example_event}))
     except (VariableDoesNotExist, TemplateSyntaxError) as e:
         raise ValidationError(_('syntax error: %s') % e)
 
@@ -1944,7 +1944,7 @@ class Desk(models.Model):
         sources = data.pop('exception_sources', [])
         unavailability_calendars = data.pop('unavailability_calendars', [])
         data = clean_import_data(cls, data)
-        desk, created = cls.objects.update_or_create(slug=data['slug'], agenda=data['agenda'], defaults=data)
+        desk = cls.objects.update_or_create(slug=data['slug'], agenda=data['agenda'], defaults=data)[0]
         for timeperiod in timeperiods:
             timeperiod['desk'] = desk
             TimePeriod.import_json(timeperiod)
diff --git a/chrono/api/views.py b/chrono/api/views.py
index d067a49..c1e60dc 100644
--- a/chrono/api/views.py
+++ b/chrono/api/views.py
@@ -2089,7 +2089,7 @@ class ResizeBooking(APIView):
     def increase(self, booking, secondary_bookings, primary_booked_places, primary_wanted_places):
         with transaction.atomic():
             bulk_bookings = []
-            for i in range(0, primary_wanted_places - primary_booked_places):
+            for dummy in range(0, primary_wanted_places - primary_booked_places):
                 bulk_bookings.append(
                     booking.clone(
                         primary_booking=booking,
diff --git a/chrono/manager/views.py b/chrono/manager/views.py
index 6642f43..1da0530 100644
--- a/chrono/manager/views.py
+++ b/chrono/manager/views.py
@@ -431,7 +431,7 @@ class ResourceMonthView(DateMixin, MonthArchiveView):
 
     def get_week_timetable_infos(self, week_index, week_end_offset=0):
         date = self.date + datetime.timedelta(week_index * 7)
-        year, week_number, dow = date.isocalendar()
+        dow = date.isocalendar()[2]
         start_date = date - datetime.timedelta(dow)
 
         interval = datetime.timedelta(minutes=60)
@@ -1317,7 +1317,7 @@ class AgendaMonthView(AgendaDateView, MonthArchiveView):
 
     def get_week_timetable_infos(self, week_index, week_end_offset=0):
         date = self.date + datetime.timedelta(week_index * 7)
-        year, week_number, dow = date.isocalendar()
+        dow = date.isocalendar()[2]
         start_date = date - datetime.timedelta(dow)
 
         interval = datetime.timedelta(minutes=60)
@@ -1358,7 +1358,7 @@ class AgendaMonthView(AgendaDateView, MonthArchiveView):
         while period <= max_date:
             left = 1
             period_end = period + interval
-            for desk_index, desk in enumerate(desks):
+            for desk in desks:
                 width = (98.0 / desks_len) - 1
                 for event in [
                     x
diff --git a/chrono/utils/requests_wrapper.py b/chrono/utils/requests_wrapper.py
index 17361d0..fcb291c 100644
--- a/chrono/utils/requests_wrapper.py
+++ b/chrono/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 = urlparse.urlparse(remote_url)[:2]
                     if remote_scheme == scheme and remote_netloc == netloc:
                         remote_service = service
                         break
@@ -104,7 +102,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/api/conftest.py b/tests/api/conftest.py
index b919bf0..f222d45 100644
--- a/tests/api/conftest.py
+++ b/tests/api/conftest.py
@@ -74,7 +74,7 @@ def meetings_agenda(mock_now):
     test_1st_weekday = (localtime(now()).weekday() + 2) % 7
     test_2nd_weekday = (localtime(now()).weekday() + 3) % 7
 
-    default_desk, created = Desk.objects.get_or_create(agenda=agenda, label='Desk 1')
+    default_desk, _ = Desk.objects.get_or_create(agenda=agenda, label='Desk 1')
 
     time_period = TimePeriod(
         weekday=test_1st_weekday,
diff --git a/tests/api/test_all.py b/tests/api/test_all.py
index 0be4dda..b01fd19 100644
--- a/tests/api/test_all.py
+++ b/tests/api/test_all.py
@@ -232,10 +232,10 @@ def test_agendas_api(app):
     resp = app.get('/api/agenda/', params={'with_open_events': '1'})
     assert len(resp.json['data']) == 1
 
-    for i in range(10):
+    for _ in range(10):
         event_agenda = Agenda.objects.create(label='Foo bar', category=category_a)
         Desk.objects.create(agenda=event_agenda, slug='_exceptions_holder')
-        event = Event.objects.create(
+        Event.objects.create(
             start_datetime=now(), places=10, agenda=event_agenda, recurrence_days=[now().weekday()]
         )
         TimePeriodException.objects.create(
diff --git a/tests/api/test_booking.py b/tests/api/test_booking.py
index 895cc6c..bdc27a6 100644
--- a/tests/api/test_booking.py
+++ b/tests/api/test_booking.py
@@ -187,7 +187,7 @@ def test_bookings_api(app, user):
 def test_bookings_api_filter_agenda(app, user):
     bookings = []
     for label in ['foobar', 'foobaz']:
-        agenda = Agenda.objects.create(label='foobar')
+        agenda = Agenda.objects.create(label=label)
         event = Event.objects.create(agenda=agenda, start_datetime=now(), places=10)
         bookings.append(Booking.objects.create(event=event, user_external_id='42'))
 
diff --git a/tests/api/test_datetimes.py b/tests/api/test_datetimes.py
index 646e5e0..e53f819 100644
--- a/tests/api/test_datetimes.py
+++ b/tests/api/test_datetimes.py
@@ -348,7 +348,7 @@ def test_waiting_list_datetimes(app, some_data, user):
     assert len([x for x in resp.json['data'] if not x.get('disabled')]) == 3
     assert event.slug in [x['id'] for x in resp.json['data']]
 
-    for i in range(event.places):
+    for _ in range(event.places):
         Booking(event=event).save()
 
     # all places are booked but all the dates are still displayed as there is a
@@ -357,7 +357,7 @@ def test_waiting_list_datetimes(app, some_data, user):
     assert len([x for x in resp.json['data'] if not x.get('disabled')]) == 3
 
     # fill the waiting list
-    for i in range(event.waiting_list_places):
+    for _ in range(event.waiting_list_places):
         Booking(event=event, in_waiting_list=True).save()
 
     # the event datetime should no longer be returned
@@ -512,7 +512,7 @@ def test_datetimes_api_meta(app, freezer):
     }
 
     def simulate_booking(event, nb_places):
-        for i in range(nb_places):
+        for _ in range(nb_places):
             Booking(event=event, user_external_id='42').save()
 
     simulate_booking(events[0], 10)
diff --git a/tests/api/test_fillslot.py b/tests/api/test_fillslot.py
index 3e8aed0..7acca28 100644
--- a/tests/api/test_fillslot.py
+++ b/tests/api/test_fillslot.py
@@ -1024,7 +1024,7 @@ def test_soldout(app, some_data, user):
     assert len([x for x in resp.json['data'] if not x.get('disabled')]) == 3
     assert event.slug in [x['id'] for x in resp.json['data']]
 
-    for i in range(event.places):
+    for _ in range(event.places):
         Booking(event=event).save()
 
     resp = app.get('/api/agenda/%s/datetimes/' % agenda_id)
@@ -1046,7 +1046,7 @@ def test_waiting_list_booking(app, some_data, user):
     event.waiting_list_places = 5
     event.save()
 
-    for i in range(event.places):
+    for _ in range(event.places):
         Booking(event=event).save()
 
     app.authorization = ('Basic', ('john.doe', 'password'))
@@ -1072,7 +1072,7 @@ def test_waiting_list_booking(app, some_data, user):
     assert resp.json['in_waiting_list'] is True
 
     # fill the waiting list
-    for i in range(event.waiting_list_places):
+    for _ in range(event.waiting_list_places):
         Booking(event=event, in_waiting_list=True).save()
 
     app.authorization = ('Basic', ('john.doe', 'password'))
@@ -1411,7 +1411,7 @@ def test_agenda_meeting_api_multiple_desk(app, meetings_agenda, user):
     assert resp.json['err_desc'] == 'no more desk available'
 
     # fill the agenda and make sure big O is O(1)
-    for idx, event_data in enumerate(resp2.json['data'][2:10]):
+    for event_data in resp2.json['data'][2:10]:
         booking_url = event_data['api']['fillslot_url']
         with CaptureQueriesContext(connection) as ctx:
             app.post(booking_url)
diff --git a/tests/manager/test_all.py b/tests/manager/test_all.py
index 1e50af7..2a53139 100644
--- a/tests/manager/test_all.py
+++ b/tests/manager/test_all.py
@@ -446,7 +446,7 @@ def test_add_agenda_and_set_role(app, admin_user, manager_user):
 
     resp = app.get('/manage/agendas/%s/settings' % agenda.id)
     resp = resp.click('Configure', href='roles')
-    role = manager_user.groups.all()[0]
+    manager_user.groups.all()[0]
     resp.form['edit_role'] = manager_user.groups.all()[0].pk
     resp = resp.form.submit().follow()
     assert 'Edit Role: Managers' in resp.text
@@ -459,7 +459,7 @@ def test_options_agenda(app, admin_user):
     agenda_events = Agenda.objects.create(label=u'Foo bar', kind='events')
     Desk.objects.create(agenda=agenda_events, slug='_exceptions_holder')
     agenda_meetings = Agenda.objects.create(label=u'Foo bar', kind='meetings')
-    agenda_virtual = Agenda.objects.create(label=u'Foo bar', kind='virtual')
+    Agenda.objects.create(label=u'Foo bar', kind='virtual')
 
     app = login(app)
     resp = app.get('/manage/agendas/%s/edit' % agenda_events.pk)
@@ -862,7 +862,7 @@ def test_delete_busy_desk(app, admin_user):
     agenda = Agenda(label=u'Foo bar', kind='meetings')
     agenda.save()
     desk_a = Desk.objects.create(agenda=agenda, label='Desk A')
-    desk_b = Desk.objects.create(agenda=agenda, label='Desk B')
+    Desk.objects.create(agenda=agenda, label='Desk B')
 
     event = Event(start_datetime=now() + datetime.timedelta(days=10), places=10, agenda=agenda, desk=desk_a)
     event.save()
@@ -2818,7 +2818,7 @@ def test_agenda_events_month_view(app, admin_user):
     assert 'abc' in resp.pyquery.find('.event-info')[3].text
     assert 'abc' in resp.pyquery.find('.event-info')[4].text
 
-    time_period_exception = TimePeriodException.objects.create(
+    TimePeriodException.objects.create(
         desk=agenda.desk_set.get(),
         start_datetime=start_datetime + datetime.timedelta(days=6),
         end_datetime=start_datetime + datetime.timedelta(days=8),
@@ -2933,7 +2933,7 @@ def test_agenda_open_events_view(app, admin_user, manager_user):
     )
     # weekly recurring event, first recurrence is in the past but second is in range
     start_datetime = now() - datetime.timedelta(days=3)
-    event = Event.objects.create(
+    Event.objects.create(
         label='event G',
         start_datetime=start_datetime,
         places=10,
@@ -4471,7 +4471,7 @@ def test_export_site(app, admin_user):
 
     agenda = Agenda.objects.create(label=u'Foo Bar', kind='events')
     Desk.objects.create(agenda=agenda, slug='_exceptions_holder')
-    unavailability_calendar = UnavailabilityCalendar.objects.create(label='Calendar 1')
+    UnavailabilityCalendar.objects.create(label='Calendar 1')
     resp = app.get('/manage/agendas/export/')
     resp = resp.form.submit()
 
@@ -4496,7 +4496,7 @@ def test_manager_agenda_roles(app, admin_user, manager_user):
     resp = app.get('/manage/agendas/%s/settings' % agenda.id)
     resp = resp.click('Configure', href='roles')
 
-    role = manager_user.groups.all()[0]
+    manager_user.groups.all()[0]
     resp.form['edit_role'] = manager_user.groups.all()[0].pk
     resp = resp.form.submit().follow()
 
@@ -4531,7 +4531,7 @@ def test_agenda_booking_colors(app, admin_user, api_user, view):
     desk = Desk.objects.create(agenda=agenda, label='New Desk')
     meetingtype = MeetingType.objects.create(agenda=agenda, label='Bar', duration=30)
     today = datetime.date.today()
-    timeperiod = TimePeriod.objects.create(
+    TimePeriod.objects.create(
         desk=desk, weekday=today.weekday(), start_time=datetime.time(10, 0), end_time=datetime.time(18, 0)
     )
 
diff --git a/tests/manager/test_event.py b/tests/manager/test_event.py
index 22e44ef..06f223f 100644
--- a/tests/manager/test_event.py
+++ b/tests/manager/test_event.py
@@ -383,7 +383,7 @@ def test_event_classes(app, admin_user):
     Desk.objects.create(agenda=agenda, slug='_exceptions_holder')
     event = Event(start_datetime=make_aware(datetime.datetime(2016, 2, 15, 17, 0)), places=10, agenda=agenda)
     event.save()
-    for i in range(2):
+    for _ in range(2):
         Booking(event=event).save()
     app = login(app)
 
@@ -395,7 +395,7 @@ def test_event_classes(app, admin_user):
     resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk))
     assert '<span class="tag">Full</span>' not in resp
 
-    for i in range(8):
+    for _ in range(8):
         Booking(event=event).save()
 
     resp = app.get('/manage/agendas/%s/settings' % agenda.id, status=200)
@@ -939,7 +939,7 @@ def test_event_cancellation_error_report(app, admin_user):
     def mocked_requests_connection_error(*args, **kwargs):
         raise requests.exceptions.ConnectionError('unreachable')
 
-    for i in range(5):
+    for _ in range(5):
         Booking.objects.create(event=event, cancel_callback_url='http://example.org/jump/trigger/')
 
     login(app)
diff --git a/tests/test_agendas.py b/tests/test_agendas.py
index 9c8f63e..f1e6b63 100644
--- a/tests/test_agendas.py
+++ b/tests/test_agendas.py
@@ -669,7 +669,7 @@ def test_sync_desks_timeperiod_exceptions_from_ics(mocked_get, capsys):
 
     mocked_get.side_effect = mocked_requests_http_forbidden_error
     call_command('sync_desks_timeperiod_exceptions')
-    out, err = capsys.readouterr()
+    err = capsys.readouterr()[1]
     assert (
         err
         == 'unable to create timeperiod exceptions for "Test 11 desk": Failed to retrieve remote calendar (http://example.com/sample.ics, HTTP error 403).\n'
@@ -960,7 +960,7 @@ def test_virtual_agenda_base_meeting_duration():
 
 def test_agenda_get_effective_time_periods(db):
     real_agenda = Agenda.objects.create(label='Real Agenda', kind='meetings')
-    meeting_type = MeetingType.objects.create(agenda=real_agenda, label='MT1')
+    MeetingType.objects.create(agenda=real_agenda, label='MT1')
     desk = Desk.objects.create(label='Real Agenda Desk1', agenda=real_agenda)
     time_period = TimePeriod.objects.create(
         weekday=0, start_time=datetime.time(10, 0), end_time=datetime.time(18, 0), desk=desk
@@ -1418,7 +1418,7 @@ def test_agendas_cancel_events_command():
     agenda = Agenda.objects.create(label='Events', kind='events')
     event = Event.objects.create(agenda=agenda, start_datetime=now(), places=10, label='Event')
 
-    for i in range(5):
+    for _ in range(5):
         Booking.objects.create(event=event, cancel_callback_url='http://example.org/jump/trigger/')
 
     event.cancellation_scheduled = True
@@ -1447,7 +1447,7 @@ def test_agendas_cancel_events_command_network_error(freezer):
         raise requests.exceptions.ConnectionError('unreachable')
 
     booking_good_url = Booking.objects.create(event=event, cancel_callback_url='http://good.org/')
-    for i in range(5):
+    for _ in range(5):
         Booking.objects.create(event=event, cancel_callback_url='http://example.org/jump/trigger/')
 
     event.cancellation_scheduled = True
@@ -1509,7 +1509,7 @@ def test_agenda_notifications_role_email(mocked_role, emails_to_members, emails,
     settings.save()
 
     # book 9/10 places to reach almost full state
-    for i in range(9):
+    for _ in range(9):
         Booking.objects.create(event=event)
     event.refresh_from_db()
     assert event.almost_full
@@ -1536,7 +1536,7 @@ def test_agenda_notifications_email_list(mailoutbox):
     settings.full_event_emails = recipients = ['hop@entrouvert.com', 'top@entrouvert.com']
     settings.save()
 
-    for i in range(10):
+    for _ in range(10):
         Booking.objects.create(event=event)
     event.refresh_from_db()
     assert event.full
@@ -1601,10 +1601,10 @@ def test_agenda_reminders(mailoutbox, freezer):
     start_datetime = now() + datetime.timedelta(days=2)
     event = Event.objects.create(agenda=agenda, start_datetime=start_datetime, places=10, label='Event')
 
-    for i in range(5):
-        booking = Booking.objects.create(event=event, user_email='t@test.org')
+    for _ in range(5):
+        Booking.objects.create(event=event, user_email='t@test.org')
     # extra booking with no email, should be ignored
-    booking = Booking.objects.create(event=event)
+    Booking.objects.create(event=event)
 
     freezer.move_to('2020-01-02 10:00')
     # not time to send reminders yet
@@ -1624,7 +1624,7 @@ def test_agenda_reminders(mailoutbox, freezer):
 
     # booking is placed the day of the event, notfication should no be sent
     freezer.move_to('2020-01-03 08:00')
-    booking = Booking.objects.create(event=event, user_email='t@test.org')
+    Booking.objects.create(event=event, user_email='t@test.org')
     call_command('send_booking_reminders')
     assert len(mailoutbox) == 0
 
@@ -1637,9 +1637,9 @@ def test_agenda_reminders_sms(freezer):
     start_datetime = now() + datetime.timedelta(days=2)
     event = Event.objects.create(agenda=agenda, start_datetime=start_datetime, places=10, label='Event')
 
-    for i in range(5):
-        booking = Booking.objects.create(event=event, user_phone_number='+336123456789')
-    booking = Booking.objects.create(event=event)
+    for _ in range(5):
+        Booking.objects.create(event=event, user_phone_number='+336123456789')
+    Booking.objects.create(event=event)
 
     freezer.move_to('2020-01-02 15:00')
     with mock.patch('chrono.utils.requests_wrapper.RequestsSession.send') as mock_send:
@@ -1738,7 +1738,7 @@ def test_agenda_reminders_retry(freezer):
 def test_agenda_reminders_email_content(mailoutbox, freezer):
     freezer.move_to('2020-01-01 14:00')
     agenda = Agenda.objects.create(label='Events', kind='events')
-    settings = AgendaReminderSettings.objects.create(
+    AgendaReminderSettings.objects.create(
         agenda=agenda, days=1, send_email=True, email_extra_info='Do no forget ID card.'
     )
     start_datetime = now() + datetime.timedelta(days=2)
@@ -1752,7 +1752,7 @@ def test_agenda_reminders_email_content(mailoutbox, freezer):
         pricing='10€',
     )
 
-    booking = Booking.objects.create(event=event, user_email='t@test.org')
+    Booking.objects.create(event=event, user_email='t@test.org')
 
     freezer.move_to('2020-01-02 15:00')
     call_command('send_booking_reminders')
@@ -1773,7 +1773,7 @@ def test_agenda_reminders_email_content(mailoutbox, freezer):
     mailoutbox.clear()
 
     freezer.move_to('2020-01-01 14:00')
-    booking = Booking.objects.create(event=event, user_email='t@test.org', form_url='https://example.org/')
+    Booking.objects.create(event=event, user_email='t@test.org', form_url='https://example.org/')
     freezer.move_to('2020-01-02 15:00')
     call_command('send_booking_reminders')
 
@@ -1793,7 +1793,7 @@ def test_agenda_reminders_sms_content(freezer):
     start_datetime = now() + datetime.timedelta(days=2)
     event = Event.objects.create(agenda=agenda, start_datetime=start_datetime, places=10, label='Pool party')
 
-    booking = Booking.objects.create(event=event, user_phone_number='+336123456789')
+    Booking.objects.create(event=event, user_phone_number='+336123456789')
 
     freezer.move_to('2020-01-02 15:00')
     with mock.patch('chrono.utils.requests_wrapper.RequestsSession.send') as mock_send:
@@ -1814,7 +1814,7 @@ def test_agenda_reminders_meetings(mailoutbox, freezer):
     agenda = Agenda.objects.create(label='Events', kind='meetings')
     desk = Desk.objects.create(agenda=agenda, label='Desk')
     meetingtype = MeetingType.objects.create(agenda=agenda, label='Bar', duration=30)
-    timeperiod = TimePeriod.objects.create(
+    TimePeriod.objects.create(
         desk=desk, weekday=now().weekday(), start_time=datetime.time(10, 0), end_time=datetime.time(18, 0)
     )
     AgendaReminderSettings.objects.create(agenda=agenda, days=2, send_email=True)
@@ -1845,7 +1845,7 @@ def test_anonymize_bookings(freezer):
         agenda=agenda, start_datetime=now() + datetime.timedelta(days=10), places=10, label='Event'
     )
 
-    for i in range(5):
+    for _ in range(5):
         Booking.objects.create(
             event=event,
             extra_data={'test': True},
@@ -2081,7 +2081,7 @@ def test_recurring_events_exceptions(freezer):
         places=5,
     )
     event.refresh_from_db()
-    start_datetime = localtime(event.start_datetime)
+    localtime(event.start_datetime)
 
     recurrences = event.get_recurrences(now(), now() + datetime.timedelta(days=7))
     assert recurrences[0].start_datetime.strftime('%m-%d') == '05-01'
@@ -2196,7 +2196,7 @@ def test_recurring_events_exceptions_update_recurrences(freezer):
     event = daily_event_no_end_date.get_or_create_event_recurrence(
         now() + datetime.timedelta(days=6, hours=2)
     )
-    booking = Booking.objects.create(event=event)
+    Booking.objects.create(event=event)
     time_period_exception.save()
 
     agenda.update_event_recurrences()
diff --git a/tests/test_import_export.py b/tests/test_import_export.py
index ff5bf62..6565fde 100644
--- a/tests/test_import_export.py
+++ b/tests/test_import_export.py
@@ -223,7 +223,7 @@ def test_import_export_event_details(app):
 def test_import_export_recurring_event(app, freezer):
     freezer.move_to('2021-01-12 12:10')
     agenda = Agenda.objects.create(label='Foo Bar', kind='events')
-    desk = Desk.objects.create(agenda=agenda, slug='_exceptions_holder')
+    Desk.objects.create(agenda=agenda, slug='_exceptions_holder')
     event = Event.objects.create(
         agenda=agenda,
         start_datetime=now(),
diff --git a/tests/test_misc.py b/tests/test_misc.py
index de2772c..4fa37de 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -225,7 +225,7 @@ def test_clean_time_period_exceptions(transactional_db):
     source_desk = TimePeriodExceptionSource.objects.create(desk=desk, settings_slug='holidays', enabled=True)
     start_datetime = datetime.datetime(year=2020, month=1, day=2)
     end_datetime = datetime.datetime(year=2020, month=1, day=3)
-    for i in range(5):
+    for _ in range(5):
         TimePeriodException.objects.create(
             desk=desk,
             source=source_desk,
@@ -241,7 +241,7 @@ def test_clean_time_period_exceptions(transactional_db):
     source_new_desk = TimePeriodExceptionSource.objects.create(
         desk=new_desk, settings_slug='holidays', enabled=True
     )
-    for i in range(5):
+    for _ in range(5):
         TimePeriodException.objects.create(
             desk=new_desk,
             source=source_new_desk,
@@ -254,7 +254,7 @@ def test_clean_time_period_exceptions(transactional_db):
     TimePeriodExceptionSource.objects.create(desk=new_desk, settings_slug='holidays', enabled=True)
 
     # wrong duplicate of exceptions, referencing original desk source
-    for i in range(5):
+    for _ in range(5):
         TimePeriodException.objects.create(
             desk=new_desk,
             source=source_desk,
diff --git a/tests/test_requests.py b/tests/test_requests.py
index ad62826..a12d01d 100644
--- a/tests/test_requests.py
+++ b/tests/test_requests.py
@@ -34,7 +34,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)
+        querystring = urlparse.urlparse(url)[4]
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['orig'][0] == 'myself'
         assert query['email'][0] == ''
@@ -44,7 +44,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)
+        querystring = urlparse.urlparse(url)[4]
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['orig'][0] == 'myself'
         assert 'email' not in query
@@ -57,7 +57,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)
+        querystring = urlparse.urlparse(url)[4]
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['orig'][0] == 'chrono'
         assert check_query(querystring, 'chrono') == True
@@ -75,7 +75,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)
+        querystring = urlparse.urlparse(url)[4]
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['NameID'][0] == 'r2d2'
         assert 'email' not in query
@@ -85,7 +85,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)
+        querystring = urlparse.urlparse(url)[4]
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['email'][0] == 'foo@example.net'
         assert 'NameID' not in query
@@ -97,7 +97,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)
+        querystring = urlparse.urlparse(url)[4]
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert 'NameID' not in query
         assert query['email'][0] == 'foo@example.net'
@@ -114,7 +114,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)
+        querystring = urlparse.urlparse(url)[4]
         query = urlparse.parse_qs(querystring, keep_blank_values=True)
         assert query['NameID'][0] == ''
         assert query['email'][0] == ''
-- 
2.30.2

