Skip to content

Commit cc63cb7

Browse files
committed
Ruff fixes
1 parent 891992c commit cc63cb7

24 files changed

Lines changed: 152 additions & 128 deletions

File tree

accounts/tests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,10 @@ def test_low_score_rejected(self):
284284
self.assertEqual(
285285
logs.output,
286286
[
287-
"WARNING:django_recaptcha.fields:ReCAPTCHA validation failed due to "
288-
"its score of 0.1 being lower than the required amount."
287+
(
288+
"WARNING:django_recaptcha.fields:ReCAPTCHA validation failed due to "
289+
"its score of 0.1 being lower than the required amount."
290+
)
289291
],
290292
)
291293

accounts/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def user_profile(request, username):
2828

2929
@login_required
3030
def edit_profile(request):
31-
profile, created = Profile.objects.get_or_create(user=request.user)
31+
profile, _created = Profile.objects.get_or_create(user=request.user)
3232
form = ProfileForm(request.POST or None, instance=profile)
3333
if form.is_valid():
3434
form.save()

aggregator/tests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,10 @@ def test_rejects_stackoverflow_questions(self):
191191
form.errors,
192192
{
193193
"feed_url": [
194-
"Stack Overflow questions tagged with 'django' will appear "
195-
"here automatically."
194+
(
195+
"Stack Overflow questions tagged with 'django' will appear "
196+
"here automatically."
197+
)
196198
]
197199
},
198200
)

checklists/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def tags(self):
399399

400400
@cached_property
401401
def latest_release(self):
402-
return [r for r in self.affected_releases if not r.is_pre_release][0]
402+
return next(r for r in self.affected_releases if not r.is_pre_release)
403403

404404
@cached_property
405405
def hashes_by_versions(self):

checklists/tests/test_models.py

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,19 @@ def assertMakeReleasePublicAdded(self, release, content):
7575
self.assertIn(expected, content)
7676
version = release.version
7777
data = [
78-
"- [ ] Add (or edit if existing) the the [release entry in the admin]"
79-
f"(https://www.djangoproject.com/admin/releases/release?version={version})",
78+
(
79+
"- [ ] Add (or edit if existing) the the [release entry in the admin]"
80+
f"(https://www.djangoproject.com/admin/releases/release?version={version})"
81+
),
8082
"- Is active: False",
8183
f"- LTS: {release.is_lts}",
8284
f"- Release date: {release.date.isoformat()}",
8385
f"- `VERSION={version} scripts/verify_release.sh`",
8486
"- `twine upload --repository django dist/*`",
85-
'- [ ] Mark the release as "active" in\n '
86-
f"https://www.djangoproject.com/admin/releases/release/{version}/change/",
87+
(
88+
'- [ ] Mark the release as "active" in\n '
89+
f"https://www.djangoproject.com/admin/releases/release/{version}/change/"
90+
),
8791
]
8892
for item in data:
8993
with self.subTest(item=item):
@@ -500,8 +504,10 @@ def test_render_checklist_affects_prerelease(self):
500504
cves = checklist.securityissue_set.all()
501505
prenotification = [
502506
"Create a new text file `prenotification-email.txt` with content",
503-
"a set of security releases will be issued on Wednesday, May 7, 2025 "
504-
"around 16:18 UTC",
507+
(
508+
"a set of security releases will be issued on Wednesday, May 7, 2025 "
509+
"around 16:18 UTC"
510+
),
505511
*(cve.headline_for_blogpost for cve in cves),
506512
"## Affected supported versions "
507513
+ " ".join(f"* Django {branch}" for branch in checklist.affected_branches),
@@ -609,14 +615,18 @@ def test_render_checklist_headline_formats(self):
609615

610616
# RST security archive uses double backticks and RST-style headings.
611617
expected_rst = [
612-
"May 7, 2025 - :cve:`2025-11111`\n"
613-
"-------------------------------\n\n"
614-
"Denial-of-service possibility in ``strip_tags()``.\n"
615-
f"`Full description\n<{checklist.blogpost_link}>`__",
616-
"May 7, 2025 - :cve:`2025-22222`\n"
617-
"-------------------------------\n\n"
618-
"Denial-of-service in ``LoginView`` and ``LogoutView``.\n"
619-
f"`Full description\n<{checklist.blogpost_link}>`__",
618+
(
619+
"May 7, 2025 - :cve:`2025-11111`\n"
620+
"-------------------------------\n\n"
621+
"Denial-of-service possibility in ``strip_tags()``.\n"
622+
f"`Full description\n<{checklist.blogpost_link}>`__"
623+
),
624+
(
625+
"May 7, 2025 - :cve:`2025-22222`\n"
626+
"-------------------------------\n\n"
627+
"Denial-of-service in ``LoginView`` and ``LogoutView``.\n"
628+
f"`Full description\n<{checklist.blogpost_link}>`__"
629+
),
620630
]
621631
for headline in expected_rst:
622632
with self.subTest(headline=headline):
@@ -1220,7 +1230,7 @@ class PreReleaseChecklistTestCase(BaseChecklistTestCaseMixin, TestCase):
12201230

12211231
def test_affected_releases(self):
12221232
feature_release = self.factory.make_feature_release_checklist("6.0")
1223-
for status, verbose in self.status_to_version.items():
1233+
for status in self.status_to_version:
12241234
release = self.factory.make_release(version=f"6.0{status}1")
12251235
with self.subTest(release=release):
12261236
checklist = self.make_checklist(
@@ -1255,7 +1265,7 @@ def test_blogpost_info(self):
12551265

12561266
def test_versions(self):
12571267
feature_release = self.factory.make_feature_release_checklist("6.0")
1258-
for status, verbose in self.status_to_version.items():
1268+
for status in self.status_to_version:
12591269
version = f"6.0{status}1"
12601270
release = self.factory.make_release(version=version)
12611271
with self.subTest(release=release):
@@ -1342,13 +1352,19 @@ def test_render_checklist(self):
13421352
feature_release_tasks = [
13431353
"- Remove the `UNDER DEVELOPMENT` header at the top of the release notes",
13441354
"- Remove the `Expected` prefix and update the release date if necessary",
1345-
"- [ ] Create a new branch from the current stable branch in the "
1346-
"[django-docs-translations repository]",
1347-
"- [ ] Update the metadata for the docs in "
1348-
"https://www.djangoproject.com/admin/docs/documentrelease/",
1355+
(
1356+
"- [ ] Create a new branch from the current stable branch in the "
1357+
"[django-docs-translations repository]"
1358+
),
1359+
(
1360+
"- [ ] Update the metadata for the docs in "
1361+
"https://www.djangoproject.com/admin/docs/documentrelease/"
1362+
),
13491363
"- Create new `DocumentRelease` objects for each language",
1350-
"- [ ] Extend [robots.docs.txt](https://github.com/django/"
1351-
"djangoproject.com/blob/main/djangoproject/static/robots.docs.txt)",
1364+
(
1365+
"- [ ] Extend [robots.docs.txt](https://github.com/django/"
1366+
"djangoproject.com/blob/main/djangoproject/static/robots.docs.txt)"
1367+
),
13521368
"- [ ] Advance the version in the download page's tables",
13531369
"- [ ] Update the current stable branch and remove the pre-release branch",
13541370
version_trove_classifier_updates,

djangoproject/settings/dev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .common import * # noqa
1+
from .common import *
22

33
ALLOWED_HOSTS = [
44
"www.djangoproject.localhost",

djangoproject/settings/docker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .dev import * # noqa: F403
1+
from .dev import *
22

33
DATABASES = {
44
"default": {

djangoproject/settings/prod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .common import * # noqa
1+
from .common import *
22

33
DOMAIN_NAME = os.getenv("DOMAIN_NAME", "djangoproject.com")
44

docs/builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def get_doc_context(self, docname, body, metatags):
6060
out_dict["python_objects_search"] = " ".join(
6161
# Keeps the code suffix to improve the search results for terms such as
6262
# "select" for QuerySet.select_related.
63-
[key.split(".")[-1] for key in python_objects.keys()]
63+
[key.split(".")[-1] for key in python_objects]
6464
)
6565
return out_dict
6666

docs/management/commands/build_doc_release.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def build_doc_release(self, release):
142142
capture_sentry_exception(e, flush=True)
143143
raise CommandError(
144144
f"sphinx-build returned an error (release {release}, "
145-
f"builder {builder}): {str(e)}" # noqa: E501
145+
f"builder {builder}): {e!s}"
146146
) from e
147147

148148
#
@@ -212,7 +212,7 @@ def gen_decoded_documents(directory):
212212
for root, dirs, files in os.walk(str(directory)):
213213
for f in files:
214214
f = Path(root, f)
215-
if not f.suffix == ".fjson":
215+
if f.suffix != ".fjson":
216216
continue
217217

218218
with f.open() as fp:

0 commit comments

Comments
 (0)