Skip to content

Commit b4a21c0

Browse files
committed
trivial: Apply ruff fixes
Signed-off-by: Stephen Finucane <[email protected]>
1 parent fd98bd4 commit b4a21c0

29 files changed

+81
-81
lines changed

manage.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import os
33
import sys
44

5-
if __name__ == "__main__":
5+
if __name__ == '__main__':
66
os.environ.setdefault(
7-
"DJANGO_SETTINGS_MODULE", "patchwork.settings.production"
7+
'DJANGO_SETTINGS_MODULE', 'patchwork.settings.production'
88
)
99

1010
import django

patchwork/api/check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class CheckSerializer(HyperlinkedModelSerializer):
3636

3737
def run_validation(self, data):
3838
if 'state' not in data or data['state'] == '':
39-
raise ValidationError({'state': ["A check must have a state."]})
39+
raise ValidationError({'state': ['A check must have a state.']})
4040

4141
for val, label in Check.STATE_CHOICES:
4242
if label != data['state']:

patchwork/forms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class BundleForm(forms.ModelForm):
6565
min_length=1,
6666
max_length=50,
6767
label='Name',
68-
error_messages={'invalid': 'Bundle names can\'t contain slashes'},
68+
error_messages={'invalid': "Bundle names can't contain slashes"},
6969
)
7070

7171
class Meta:
@@ -203,7 +203,7 @@ def save(self, instance, commit=True):
203203
opts = instance.__class__._meta
204204
if self.errors:
205205
raise ValueError(
206-
"The %s could not be changed because the data "
206+
'The %s could not be changed because the data '
207207
"didn't validate." % opts.object_name
208208
)
209209
data = self.cleaned_data

patchwork/management/commands/cron.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def handle(self, *args, **kwargs):
1919
errors = send_notifications()
2020
for recipient, error in errors:
2121
self.stderr.write(
22-
"Failed sending to %s: %s" % (recipient.email, error)
22+
'Failed sending to %s: %s' % (recipient.email, error)
2323
)
2424

2525
expire_notifications()

patchwork/management/commands/parsemail.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def handle(self, *args, **options):
4444
logger.info('Parsing mail loaded from stdin')
4545
mail = email.message_from_binary_file(sys.stdin.buffer)
4646
except AttributeError:
47-
logger.warning("Broken email ignored")
47+
logger.warning('Broken email ignored')
4848
return
4949

5050
# it's important to get exit codes correct here. The key is to allow

patchwork/migrations/0001_squashed_0040_add_related_patches.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ class Migration(migrations.Migration):
248248
models.CharField(
249249
blank=True,
250250
help_text=b"URL format for the list archive's "
251-
b"Message-ID redirector. {} will be "
252-
b"replaced by the Message-ID.",
251+
b'Message-ID redirector. {} will be '
252+
b'replaced by the Message-ID.',
253253
max_length=2000,
254254
),
255255
),
@@ -424,7 +424,7 @@ class Migration(migrations.Migration):
424424
models.BooleanField(
425425
default=True,
426426
help_text=b"Show a column displaying this tag's count "
427-
b"in the patch list view",
427+
b'in the patch list view',
428428
),
429429
),
430430
],

patchwork/migrations/0007_move_comment_content_to_patch_content.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
def copy_comment_field(apps, schema_editor):
55
if connection.vendor == 'postgresql':
66
schema_editor.execute(
7-
'''
7+
"""
88
UPDATE patchwork_patch
99
SET content = patchwork_comment.content
1010
FROM patchwork_comment
1111
WHERE patchwork_patch.id=patchwork_comment.patch_id
1212
AND patchwork_patch.msgid=patchwork_comment.msgid
13-
'''
13+
"""
1414
)
1515
elif connection.vendor == 'mysql':
1616
schema_editor.execute(
17-
'''
17+
"""
1818
UPDATE patchwork_patch, patchwork_comment
1919
SET patchwork_patch.content = patchwork_comment.content
2020
WHERE patchwork_patch.id=patchwork_comment.patch_id
2121
AND patchwork_patch.msgid=patchwork_comment.msgid
22-
'''
22+
"""
2323
)
2424
else:
2525
Comment = apps.get_model('patchwork', 'Comment')
@@ -41,21 +41,21 @@ def copy_comment_field(apps, schema_editor):
4141
def remove_duplicate_comments(apps, schema_editor):
4242
if connection.vendor == 'postgresql':
4343
schema_editor.execute(
44-
'''
44+
"""
4545
DELETE FROM patchwork_comment
4646
USING patchwork_patch
4747
WHERE patchwork_patch.id=patchwork_comment.patch_id
4848
AND patchwork_patch.msgid=patchwork_comment.msgid
49-
'''
49+
"""
5050
)
5151
elif connection.vendor == 'mysql':
5252
schema_editor.execute(
53-
'''
53+
"""
5454
DELETE FROM patchwork_comment
5555
USING patchwork_patch, patchwork_comment
5656
WHERE patchwork_patch.id=patchwork_comment.patch_id
5757
AND patchwork_patch.msgid=patchwork_comment.msgid
58-
'''
58+
"""
5959
)
6060
else:
6161
Comment = apps.get_model('patchwork', 'Comment')

patchwork/migrations/0010_migrate_data_from_submission_to_patch.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ class Migration(migrations.Migration):
88

99
operations = [
1010
migrations.RunSQL(
11-
'''INSERT INTO patchwork_patch
11+
"""INSERT INTO patchwork_patch
1212
(submission_ptr_id, diff2, commit_ref2, pull_url2,
1313
delegate2_id, state2_id, archived2, hash2)
1414
SELECT id, diff, commit_ref, pull_url, delegate_id, state_id,
1515
archived, hash
1616
FROM patchwork_submission
17-
''',
18-
'''UPDATE patchwork_submission SET
17+
""",
18+
"""UPDATE patchwork_submission SET
1919
diff=diff2, commit_ref=commit_ref2, pull_url=pull_url2,
2020
delegate_id=delegate2_id, state_id=state2_id,
2121
archived=archived2, hash=hash2
2222
FROM patchwork_patch WHERE
2323
patchwork_submission.id = patchwork_patch.submission_ptr_id
24-
''',
24+
""",
2525
),
2626
]

patchwork/migrations/0020_tag_show_column.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Migration(migrations.Migration):
1313
field=models.BooleanField(
1414
default=True,
1515
help_text=b"Show a column displaying this tag's count in the "
16-
b"patch list view",
16+
b'patch list view',
1717
),
1818
),
1919
]

patchwork/migrations/0024_patch_patch_project.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class Migration(migrations.Migration):
2626
),
2727
# as with 10, this will break if you use non-default table names
2828
migrations.RunSQL(
29-
'''UPDATE patchwork_patch SET patch_project_id =
29+
"""UPDATE patchwork_patch SET patch_project_id =
3030
(SELECT project_id FROM patchwork_submission
3131
WHERE patchwork_submission.id =
32-
patchwork_patch.submission_ptr_id);'''
32+
patchwork_patch.submission_ptr_id);"""
3333
),
3434
migrations.AlterField(
3535
model_name='patch',

patchwork/migrations/0035_project_list_archive_url_format.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Migration(migrations.Migration):
1313
field=models.CharField(
1414
blank=True,
1515
help_text=b"URL format for the list archive's Message-ID "
16-
b"redirector. {} will be replaced by the "
17-
b"Message-ID.",
16+
b'redirector. {} will be replaced by the '
17+
b'Message-ID.',
1818
max_length=2000,
1919
),
2020
),

patchwork/migrations/0041_python3.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class Migration(migrations.Migration):
229229
field=models.CharField(
230230
blank=True,
231231
help_text="URL format for the list archive's Message-ID "
232-
"redirector. {} will be replaced by the Message-ID.",
232+
'redirector. {} will be replaced by the Message-ID.',
233233
max_length=2000,
234234
),
235235
),
@@ -314,7 +314,7 @@ class Migration(migrations.Migration):
314314
field=models.BooleanField(
315315
default=True,
316316
help_text="Show a column displaying this tag's count in the "
317-
"patch list view",
317+
'patch list view',
318318
),
319319
),
320320
migrations.AlterField(

patchwork/models.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Project(models.Model):
8888
max_length=2000,
8989
blank=True,
9090
help_text="URL format for the list archive's Message-ID redirector. "
91-
"{} will be replaced by the Message-ID.",
91+
'{} will be replaced by the Message-ID.',
9292
)
9393
commit_url_format = models.CharField(
9494
max_length=2000,
@@ -270,7 +270,7 @@ class Tag(models.Model):
270270
)
271271
show_column = models.BooleanField(
272272
help_text='Show a column displaying this'
273-
' tag\'s count in the patch list view',
273+
" tag's count in the patch list view",
274274
default=True,
275275
)
276276

@@ -319,10 +319,10 @@ def with_tag_counts(self, project=None):
319319

320320
for tag in tags:
321321
select[tag.attr_name] = (
322-
"coalesce("
323-
"(SELECT count FROM patchwork_patchtag"
324-
" WHERE patchwork_patchtag.patch_id=patchwork_patch.id"
325-
" AND patchwork_patchtag.tag_id=%s), 0)"
322+
'coalesce('
323+
'(SELECT count FROM patchwork_patchtag'
324+
' WHERE patchwork_patchtag.patch_id=patchwork_patch.id'
325+
' AND patchwork_patchtag.tag_id=%s), 0)'
326326
)
327327
select_params.append(tag.id)
328328

patchwork/parser.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def find_project(mail, list_id=None):
207207

208208
if not project:
209209
logger.debug(
210-
"Could not find a valid project for given list-id and " "subject."
210+
'Could not find a valid project for given list-id and ' 'subject.'
211211
)
212212

213213
return project
@@ -412,7 +412,7 @@ def get_original_sender(mail, name, email):
412412
cc_headers = mail.get_all('Cc') or []
413413
for header in reply_to_headers + cc_headers:
414414
header = clean_header(header)
415-
addrs = header.split(",")
415+
addrs = header.split(',')
416416
for addr in addrs:
417417
new_name, new_email = split_from_header(addr)
418418
if new_name:
@@ -520,8 +520,8 @@ def find_message_id(mail):
520520
# about this
521521
logger.info(
522522
"Malformed 'Message-Id' header. The 'msg-id' component should be "
523-
"surrounded by angle brackets. Saving raw header. This may "
524-
"include comments and extra whitespace."
523+
'surrounded by angle brackets. Saving raw header. This may '
524+
'include comments and extra whitespace.'
525525
)
526526
msgid = header.strip()
527527

@@ -547,8 +547,8 @@ def find_references(mail):
547547
else:
548548
logger.info(
549549
"Malformed 'In-Reply-To' header. The 'msg-id' component "
550-
"should be surrounded by angle brackets. Saving raw header. "
551-
"This may include comments and extra whitespace."
550+
'should be surrounded by angle brackets. Saving raw header. '
551+
'This may include comments and extra whitespace.'
552552
)
553553
ref = header.strip()
554554
refs.append(ref)

patchwork/templatetags/patch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def patch_tags(patch):
2323
count = getattr(patch, tag.attr_name)
2424
titles.append('%d %s' % (count, tag.name))
2525
if count == 0:
26-
counts.append("-")
26+
counts.append('-')
2727
else:
2828
counts.append(str(count))
2929

patchwork/tests/api/test_event.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,18 @@ def test_order_by_date_default(self):
202202
self._create_events()
203203

204204
resp = self.client.get(self.api_url())
205-
events = Event.objects.order_by("-date").all()
205+
events = Event.objects.order_by('-date').all()
206206
for api_event, event in zip(resp.data, events):
207-
self.assertEqual(api_event["id"], event.id)
207+
self.assertEqual(api_event['id'], event.id)
208208

209209
def test_order_by_date_ascending(self):
210210
"""Assert the default ordering is by date descending."""
211211
self._create_events()
212212

213213
resp = self.client.get(self.api_url(), {'order': 'date'})
214-
events = Event.objects.order_by("date").all()
214+
events = Event.objects.order_by('date').all()
215215
for api_event, event in zip(resp.data, events):
216-
self.assertEqual(api_event["id"], event.id)
216+
self.assertEqual(api_event['id'], event.id)
217217

218218
def test_create(self):
219219
"""Ensure creates aren't allowed"""

patchwork/tests/api/test_patch.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def _create_patch(self, **kwargs):
8181
state=state_obj,
8282
project=project_obj,
8383
submitter=person_obj,
84-
**kwargs
84+
**kwargs,
8585
)
8686

8787
return patch_obj
@@ -366,7 +366,7 @@ def test_update_maintainer_version_1_0(self):
366366

367367
self.client.force_authenticate(user=user)
368368
resp = self.client.patch(
369-
self.api_url(patch.id, version="1.1"),
369+
self.api_url(patch.id, version='1.1'),
370370
{'state': state.slug, 'delegate': user.id},
371371
)
372372
self.assertEqual(status.HTTP_200_OK, resp.status_code, resp)

0 commit comments

Comments
 (0)