Skip to content

Commit aa306e5

Browse files
Paul Schillingswrichards
Paul Schilling
authored andcommitted
Refactor for compliance with PEP8-naming
1 parent 624507e commit aa306e5

20 files changed

+77
-72
lines changed

ruff.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ select = [
5454
"B904",
5555
# https://docs.astral.sh/ruff/rules/#pep8-naming-n
5656
"N",
57-
>>>>>>> 1fccb49c (Enable ruff pep8-naming rule)
5857
]
5958
ignore = [
6059
# Whitespace before ':' (conflicts with Black)
@@ -77,7 +76,7 @@ ignore = [
7776
"SIM102",
7877
# Variables in function scope should be lower-case
7978
"N806",
80-
# Cariables in class scope should not be mixed-case
79+
# Variables in class scope should not be mixed-case
8180
"N815",
8281
# Exception name should be named with Error suffix
8382
"N818",

src/open_inwoner/accounts/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Meta:
6262
# XXX: enabling this requires the tests/mocks to be updated. exercise left to the
6363
# reader.
6464
@classproperty
65-
def oidcdb_check_idp_availability(cls):
65+
def oidcdb_check_idp_availability(cls): # noqa: N805
6666
return False
6767

6868
@property
@@ -89,7 +89,7 @@ class Meta:
8989
# XXX: enabling this requires the tests/mocks to be updated. exercise left to the
9090
# reader.
9191
@classproperty
92-
def oidcdb_check_idp_availability(cls):
92+
def oidcdb_check_idp_availability(cls): # noqa: N805
9393
return False
9494

9595
@property

src/open_inwoner/accounts/tests/test_auth.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import requests_mock
1212
from django_webtest import WebTest
1313
from furl import furl
14-
from pyquery import PyQuery as PQ
14+
from pyquery import PyQuery
1515

1616
from open_inwoner.accounts.choices import NotificationChannelChoice
1717
from open_inwoner.accounts.signals import KvKClient, update_user_on_login
@@ -2008,7 +2008,7 @@ def test_password_change_form_done_custom_template_is_rendered(self):
20082008
def test_password_change_button_is_rendered_with_default_login_type(self):
20092009
response = self.app.get(reverse("profile:detail"), user=self.user)
20102010

2011-
doc = PQ(response.content)
2011+
doc = PyQuery(response.content)
20122012
link = doc.find("[aria-label='Wachtwoord']")[0]
20132013
self.assertTrue(doc(link).is_("a"))
20142014

@@ -2018,7 +2018,7 @@ def test_password_change_button_is_not_rendered_with_digid_login_type(self):
20182018
)
20192019
response = self.app.get(reverse("profile:detail"), user=digid_user)
20202020

2021-
doc = PQ(response.content)
2021+
doc = PyQuery(response.content)
20222022
links = doc.find("[aria-label='Wachtwoord']")
20232023
self.assertEqual(len(links), 0)
20242024

src/open_inwoner/accounts/tests/test_commands.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class DeleteContactInvitationsTest(AssertTimelineLogMixin, TestCase):
1313
@freeze_time("2023-09-26", as_arg=True)
14-
def test_delete_expired_invitations(frozen_time, self):
14+
def test_delete_expired_invitations(frozen_time, self): # noqa: N805
1515
user = UserFactory(
1616
first_name="Johann Maria Salvadore",
1717
infix="van de",

src/open_inwoner/accounts/tests/test_oidc_views.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from django_webtest import DjangoTestApp, DjangoWebtestResponse, WebTest
1616
from furl import furl
1717
from mozilla_django_oidc_db.models import OpenIDConnectConfig
18-
from pyquery import PyQuery as PQ
18+
from pyquery import PyQuery
1919

2020
from open_inwoner.accounts.views.auth_oidc import (
2121
GENERIC_DIGID_ERROR_MSG,
@@ -48,7 +48,7 @@ def perform_oidc_login(
4848

4949
login_response = app.get(login_url)
5050

51-
doc = PQ(login_response.content)
51+
doc = PyQuery(login_response.content)
5252
login_link = doc.find(f".link--{login_type}")
5353
init_url = login_link.attr("href")
5454

@@ -817,7 +817,7 @@ def test_login_error_message_mapped_in_config(
817817
)
818818

819819
login_response = self.client.get(error_response.url)
820-
doc = PQ(login_response.content)
820+
doc = PyQuery(login_response.content)
821821
error_msg = doc.find(".notification__content").text()
822822

823823
self.assertEqual(error_msg, "Je hebt het inloggen met DigiD geannuleerd.")
@@ -874,7 +874,7 @@ def test_login_error_message_not_mapped_in_config(
874874
)
875875

876876
login_response = self.client.get(error_response.url)
877-
doc = PQ(login_response.content)
877+
doc = PyQuery(login_response.content)
878878
error_msg = doc.find(".notification__content").text()
879879

880880
self.assertEqual(error_msg, str(GENERIC_DIGID_ERROR_MSG))
@@ -927,7 +927,7 @@ def test_login_validation_error(
927927
)
928928

929929
login_response = self.client.get(error_response.url)
930-
doc = PQ(login_response.content)
930+
doc = PyQuery(login_response.content)
931931
error_msg = doc.find(".notification__content").text()
932932

933933
self.assertEqual(error_msg, str(GENERIC_DIGID_ERROR_MSG))
@@ -1438,7 +1438,7 @@ def test_login_error_message_mapped_in_config(
14381438
)
14391439

14401440
login_response = self.client.get(error_response.url)
1441-
doc = PQ(login_response.content)
1441+
doc = PyQuery(login_response.content)
14421442
error_msg = doc.find(".notification__content").text()
14431443

14441444
self.assertEqual(error_msg, "Je hebt het inloggen met eHerkenning geannuleerd.")
@@ -1497,7 +1497,7 @@ def test_login_error_message_not_mapped_in_config(
14971497
)
14981498

14991499
login_response = self.client.get(error_response.url)
1500-
doc = PQ(login_response.content)
1500+
doc = PyQuery(login_response.content)
15011501
error_msg = doc.find(".notification__content").text()
15021502

15031503
self.assertEqual(error_msg, str(GENERIC_EHERKENNING_ERROR_MSG))
@@ -1557,7 +1557,7 @@ def test_login_validation_error(
15571557
)
15581558

15591559
login_response = self.client.get(error_response.url)
1560-
doc = PQ(login_response.content)
1560+
doc = PyQuery(login_response.content)
15611561
error_msg = doc.find(".notification__content").text()
15621562

15631563
self.assertEqual(error_msg, str(GENERIC_EHERKENNING_ERROR_MSG))

src/open_inwoner/accounts/tests/test_profile_views.py

+28-22
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import requests_mock
1313
from django_webtest import WebTest
1414
from freezegun import freeze_time
15-
from pyquery import PyQuery as PQ
15+
from pyquery import PyQuery
1616
from webtest import Upload
1717

1818
from open_inwoner.accounts.choices import NotificationChannelChoice, StatusChoices
@@ -153,7 +153,7 @@ def test_user_information_profile_page(self, m):
153153
self.assertNotContains(response, "Bedrijfsgegevens")
154154

155155
# check notification preferences displayed
156-
doc = PQ(response.content)
156+
doc = PyQuery(response.content)
157157

158158
notifications_text = doc.find("#profile-notifications")[0].text_content()
159159
self.assertIn("Mijn Berichten", notifications_text)
@@ -171,7 +171,7 @@ def test_admin_disable_options(self, m):
171171

172172
response = self.app.get(self.url, user=self.user)
173173

174-
doc = PQ(response.content)
174+
doc = PyQuery(response.content)
175175

176176
self.assertEqual(doc.find("#profile-notifications"), [])
177177

@@ -250,7 +250,7 @@ def test_info_eherkenning_user(self):
250250
self.assertContains(response, "Fantasiestraat 42")
251251
self.assertContains(response, "1234 XY The good place")
252252

253-
doc = PQ(response.content)
253+
doc = PyQuery(response.content)
254254

255255
business_section = doc.find("#business-overview")[0]
256256
self.assertEqual(business_section.text.strip(), "Bedrijfsgegevens")
@@ -1337,13 +1337,13 @@ def test_save_form_with_errors(self, m):
13371337
)
13381338

13391339
self.assertEqual(
1340-
PQ(subscribe_error).text(),
1340+
PyQuery(subscribe_error).text(),
13411341
_(
13421342
"Something went wrong while trying to subscribe to '{list_name}', please try again later"
13431343
).format(list_name="Nieuwsbrief2"),
13441344
)
13451345
self.assertEqual(
1346-
PQ(unsubscribe_error).text(),
1346+
PyQuery(unsubscribe_error).text(),
13471347
_(
13481348
"Something went wrong while trying to unsubscribe from '{list_name}', please try again later"
13491349
).format(list_name="Nieuwsbrief1"),
@@ -1500,30 +1500,36 @@ def test_render_list_if_appointments_are_found(self, m):
15001500

15011501
self.assertNotIn("Old appointment", response.text)
15021502

1503-
self.assertEqual(PQ(cards[0]).find(".card__heading-2").text(), "Paspoort")
1503+
self.assertEqual(PyQuery(cards[0]).find(".card__heading-2").text(), "Paspoort")
15041504

1505-
passport_appointment = PQ(cards[0]).find("ul").children()
1505+
passport_appointment = PyQuery(cards[0]).find("ul").children()
15061506

1507-
self.assertEqual(PQ(passport_appointment[0]).text(), "Datum\n1 januari 2020")
1508-
self.assertEqual(PQ(passport_appointment[1]).text(), "Tijd\n13:00 uur")
1509-
self.assertEqual(PQ(passport_appointment[2]).text(), "Locatie\nHoofdkantoor")
1510-
self.assertEqual(PQ(passport_appointment[3]).text(), "Dam 1")
1511-
self.assertEqual(PQ(passport_appointment[4]).text(), "1234 ZZ Amsterdam")
15121507
self.assertEqual(
1513-
PQ(cards[0]).find("a").attr("href"),
1508+
PyQuery(passport_appointment[0]).text(), "Datum\n1 januari 2020"
1509+
)
1510+
self.assertEqual(PyQuery(passport_appointment[1]).text(), "Tijd\n13:00 uur")
1511+
self.assertEqual(
1512+
PyQuery(passport_appointment[2]).text(), "Locatie\nHoofdkantoor"
1513+
)
1514+
self.assertEqual(PyQuery(passport_appointment[3]).text(), "Dam 1")
1515+
self.assertEqual(PyQuery(passport_appointment[4]).text(), "1234 ZZ Amsterdam")
1516+
self.assertEqual(
1517+
PyQuery(cards[0]).find("a").attr("href"),
15141518
f"{self.data.config.booking_base_url}{self.data.appointment_passport.publicId}",
15151519
)
15161520

1517-
self.assertEqual(PQ(cards[1]).find(".card__heading-2").text(), "ID kaart")
1521+
self.assertEqual(PyQuery(cards[1]).find(".card__heading-2").text(), "ID kaart")
15181522

1519-
id_card_appointment = PQ(cards[1]).find("ul").children()
1523+
id_card_appointment = PyQuery(cards[1]).find("ul").children()
15201524

1521-
self.assertEqual(PQ(id_card_appointment[0]).text(), "Datum\n6 maart 2020")
1522-
self.assertEqual(PQ(id_card_appointment[1]).text(), "Tijd\n11:30 uur")
1523-
self.assertEqual(PQ(id_card_appointment[2]).text(), "Locatie\nHoofdkantoor")
1524-
self.assertEqual(PQ(id_card_appointment[3]).text(), "Wall Street 1")
1525-
self.assertEqual(PQ(id_card_appointment[4]).text(), "1111 AA New York")
1525+
self.assertEqual(PyQuery(id_card_appointment[0]).text(), "Datum\n6 maart 2020")
1526+
self.assertEqual(PyQuery(id_card_appointment[1]).text(), "Tijd\n11:30 uur")
1527+
self.assertEqual(
1528+
PyQuery(id_card_appointment[2]).text(), "Locatie\nHoofdkantoor"
1529+
)
1530+
self.assertEqual(PyQuery(id_card_appointment[3]).text(), "Wall Street 1")
1531+
self.assertEqual(PyQuery(id_card_appointment[4]).text(), "1111 AA New York")
15261532
self.assertEqual(
1527-
PQ(cards[1]).find("a").attr("href"),
1533+
PyQuery(cards[1]).find("a").attr("href"),
15281534
f"{self.data.config.booking_base_url}{self.data.appointment_idcard.publicId}",
15291535
)

src/open_inwoner/accounts/views/profile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from open_inwoner.laposta.models import LapostaConfig
3131
from open_inwoner.openklant.services import eSuiteKlantenService
3232
from open_inwoner.plans.models import Plan
33-
from open_inwoner.qmatic.client import NoServiceConfigured, QmaticClient
33+
from open_inwoner.qmatic.client import NoServiceConfigured, qmatic_client_factory
3434
from open_inwoner.questionnaire.models import QuestionnaireStep
3535
from open_inwoner.utils.views import CommonPageMixin, LogMixin
3636

@@ -414,7 +414,7 @@ def get_context_data(self, **kwargs) -> dict[str, Any]:
414414
context["appointments"] = []
415415
else:
416416
try:
417-
client = QmaticClient()
417+
client = qmatic_client_factory()
418418
except NoServiceConfigured:
419419
logger.exception("Error occurred while creating Qmatic client")
420420
context["appointments"] = []

src/open_inwoner/cms/plugins/cms_plugins/appointments.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from cms.plugin_pool import plugin_pool
77

88
from open_inwoner.cms.plugins.models.appointments import UserAppointments
9-
from open_inwoner.qmatic.client import NoServiceConfigured, QmaticClient
9+
from open_inwoner.qmatic.client import NoServiceConfigured, qmatic_client_factory
1010

1111
logger = logging.getLogger(__name__)
1212

@@ -24,7 +24,7 @@ def render(self, context, instance, placeholder):
2424
appointments = []
2525
else:
2626
try:
27-
client = QmaticClient()
27+
client = qmatic_client_factory()
2828
except NoServiceConfigured:
2929
logger.exception("Error occurred while creating Qmatic client")
3030
appointments = []

src/open_inwoner/cms/plugins/tests/test_appointments.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import requests_mock
55
from freezegun import freeze_time
6-
from pyquery import PyQuery as PQ
6+
from pyquery import PyQuery
77

88
from open_inwoner.cms.tests import cms_tools
99
from open_inwoner.qmatic.tests.data import QmaticMockData
@@ -33,16 +33,16 @@ def test_plugin(self, m):
3333
self.assertIn("ID kaart", html)
3434
self.assertNotIn("Old appointment", html)
3535

36-
pyquery = PQ(html)
36+
pyquery = PyQuery(html)
3737

3838
# test item
3939
items = pyquery.find(".card-container .card")
4040
self.assertEqual(len(items), 2)
4141

42-
aanvraag_paspoort_date = PQ(items.find("p.tabled__value")[0]).text()
43-
aanvraag_paspoort_title = PQ(items.find(".plugin-card__heading")[0]).text()
44-
aanvraag_id_kaart_date = PQ(items.find("p.tabled__value")[1]).text()
45-
aanvraag_id_kaart_title = PQ(items.find(".plugin-card__heading")[1]).text()
42+
aanvraag_paspoort_date = PyQuery(items.find("p.tabled__value")[0]).text()
43+
aanvraag_paspoort_title = PyQuery(items.find(".plugin-card__heading")[0]).text()
44+
aanvraag_id_kaart_date = PyQuery(items.find("p.tabled__value")[1]).text()
45+
aanvraag_id_kaart_title = PyQuery(items.find(".plugin-card__heading")[1]).text()
4646

4747
self.assertEqual(aanvraag_paspoort_date, "1 januari 2020 om 13:00 uur")
4848
self.assertEqual(aanvraag_paspoort_title, "Paspoort")

src/open_inwoner/cms/plugins/tests/test_userfeed.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from django.utils.html import strip_tags
33
from django.utils.translation import ngettext
44

5-
from pyquery import PyQuery as PQ
5+
from pyquery import PyQuery
66

77
from open_inwoner.accounts.tests.factories import UserFactory
88
from open_inwoner.cms.tests import cms_tools
@@ -26,7 +26,7 @@ def test_plugin(self):
2626
self.assertIn("Test message", html)
2727
self.assertIn("Hello", html)
2828

29-
pyquery = PQ(html)
29+
pyquery = PyQuery(html)
3030

3131
# test summary
3232
summaries = pyquery.find(".userfeed__summary .userfeed__list-item")

src/open_inwoner/cms/tests/test_middleware.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.urls import reverse
44

55
from maykin_2fa.test import disable_admin_mfa
6-
from pyquery import PyQuery as pq
6+
from pyquery import PyQuery
77

88
from open_inwoner.cms.tests import cms_tools
99
from open_inwoner.cms.utils.middleware import DropToolbarMiddleware
@@ -61,11 +61,11 @@ def test_staff_verified_with_2fa_shows_toolbar(self):
6161
self.assertHasToolbar(response)
6262

6363
def assertHasToolbar(self, response):
64-
d = pq(response.content.decode("utf8"))
64+
d = PyQuery(response.content.decode("utf8"))
6565
if not len(d(".cms-toolbar")):
6666
self.fail("cannot locate element with class '.cms-toolbar'")
6767

6868
def assertNotHasToolbar(self, response):
69-
d = pq(response.content.decode("utf8"))
69+
d = PyQuery(response.content.decode("utf8"))
7070
if len(d(".cms-toolbar")):
7171
self.fail("found element with class '.cms-toolbar'")

src/open_inwoner/conf/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import sentry_sdk
66
from celery.schedules import crontab
7-
from easy_thumbnails.conf import Settings as thumbnail_settings
7+
from easy_thumbnails.conf import Settings as ThumbnailSettings
88
from log_outgoing_requests.formatters import HttpFormatter
99

1010
from .utils import config, get_sentry_integrations
@@ -800,7 +800,7 @@
800800
THUMBNAIL_PROCESSORS = (
801801
"filer.thumbnail_processors.scale_and_crop_with_subject_location",
802802
"image_cropping.thumbnail_processors.crop_corners",
803-
) + thumbnail_settings.THUMBNAIL_PROCESSORS
803+
) + ThumbnailSettings.THUMBNAIL_PROCESSORS
804804

805805
THUMBNAIL_HIGH_RESOLUTION = True
806806

src/open_inwoner/configurations/tests/test_kcm_survey.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from django.test import TestCase
44

5-
from pyquery import PyQuery as PQ
5+
from pyquery import PyQuery
66

77
from open_inwoner.cms.profile.cms_apps import ProfileApphook
88
from open_inwoner.cms.tests import cms_tools
@@ -25,7 +25,7 @@ def setUp(self):
2525
def test_kcm_survey_configured(self, mock_config):
2626
response = self.client.get("/")
2727

28-
doc = PQ(response.content)
28+
doc = PyQuery(response.content)
2929

3030
self.assertEqual(len(doc.find(self.css_selector)), 1)
3131

@@ -46,6 +46,6 @@ def test_kcm_survey_not_configured(self):
4646
):
4747
response = self.client.get("/")
4848

49-
doc = PQ(response.content)
49+
doc = PyQuery(response.content)
5050

5151
self.assertEqual(len(doc.find(self.css_selector)), 0)

0 commit comments

Comments
 (0)