Skip to content

Commit

Permalink
trivial: Apply ruff fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Finucane <[email protected]>
  • Loading branch information
stephenfin committed Jan 16, 2024
1 parent fd98bd4 commit b4a21c0
Show file tree
Hide file tree
Showing 29 changed files with 81 additions and 81 deletions.
4 changes: 2 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import os
import sys

if __name__ == "__main__":
if __name__ == '__main__':
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "patchwork.settings.production"
'DJANGO_SETTINGS_MODULE', 'patchwork.settings.production'
)

import django
Expand Down
2 changes: 1 addition & 1 deletion patchwork/api/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CheckSerializer(HyperlinkedModelSerializer):

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

for val, label in Check.STATE_CHOICES:
if label != data['state']:
Expand Down
4 changes: 2 additions & 2 deletions patchwork/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class BundleForm(forms.ModelForm):
min_length=1,
max_length=50,
label='Name',
error_messages={'invalid': 'Bundle names can\'t contain slashes'},
error_messages={'invalid': "Bundle names can't contain slashes"},
)

class Meta:
Expand Down Expand Up @@ -203,7 +203,7 @@ def save(self, instance, commit=True):
opts = instance.__class__._meta
if self.errors:
raise ValueError(
"The %s could not be changed because the data "
'The %s could not be changed because the data '
"didn't validate." % opts.object_name
)
data = self.cleaned_data
Expand Down
2 changes: 1 addition & 1 deletion patchwork/management/commands/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def handle(self, *args, **kwargs):
errors = send_notifications()
for recipient, error in errors:
self.stderr.write(
"Failed sending to %s: %s" % (recipient.email, error)
'Failed sending to %s: %s' % (recipient.email, error)
)

expire_notifications()
2 changes: 1 addition & 1 deletion patchwork/management/commands/parsemail.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def handle(self, *args, **options):
logger.info('Parsing mail loaded from stdin')
mail = email.message_from_binary_file(sys.stdin.buffer)
except AttributeError:
logger.warning("Broken email ignored")
logger.warning('Broken email ignored')
return

# it's important to get exit codes correct here. The key is to allow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ class Migration(migrations.Migration):
models.CharField(
blank=True,
help_text=b"URL format for the list archive's "
b"Message-ID redirector. {} will be "
b"replaced by the Message-ID.",
b'Message-ID redirector. {} will be '
b'replaced by the Message-ID.',
max_length=2000,
),
),
Expand Down Expand Up @@ -424,7 +424,7 @@ class Migration(migrations.Migration):
models.BooleanField(
default=True,
help_text=b"Show a column displaying this tag's count "
b"in the patch list view",
b'in the patch list view',
),
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
def copy_comment_field(apps, schema_editor):
if connection.vendor == 'postgresql':
schema_editor.execute(
'''
"""
UPDATE patchwork_patch
SET content = patchwork_comment.content
FROM patchwork_comment
WHERE patchwork_patch.id=patchwork_comment.patch_id
AND patchwork_patch.msgid=patchwork_comment.msgid
'''
"""
)
elif connection.vendor == 'mysql':
schema_editor.execute(
'''
"""
UPDATE patchwork_patch, patchwork_comment
SET patchwork_patch.content = patchwork_comment.content
WHERE patchwork_patch.id=patchwork_comment.patch_id
AND patchwork_patch.msgid=patchwork_comment.msgid
'''
"""
)
else:
Comment = apps.get_model('patchwork', 'Comment')
Expand All @@ -41,21 +41,21 @@ def copy_comment_field(apps, schema_editor):
def remove_duplicate_comments(apps, schema_editor):
if connection.vendor == 'postgresql':
schema_editor.execute(
'''
"""
DELETE FROM patchwork_comment
USING patchwork_patch
WHERE patchwork_patch.id=patchwork_comment.patch_id
AND patchwork_patch.msgid=patchwork_comment.msgid
'''
"""
)
elif connection.vendor == 'mysql':
schema_editor.execute(
'''
"""
DELETE FROM patchwork_comment
USING patchwork_patch, patchwork_comment
WHERE patchwork_patch.id=patchwork_comment.patch_id
AND patchwork_patch.msgid=patchwork_comment.msgid
'''
"""
)
else:
Comment = apps.get_model('patchwork', 'Comment')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ class Migration(migrations.Migration):

operations = [
migrations.RunSQL(
'''INSERT INTO patchwork_patch
"""INSERT INTO patchwork_patch
(submission_ptr_id, diff2, commit_ref2, pull_url2,
delegate2_id, state2_id, archived2, hash2)
SELECT id, diff, commit_ref, pull_url, delegate_id, state_id,
archived, hash
FROM patchwork_submission
''',
'''UPDATE patchwork_submission SET
""",
"""UPDATE patchwork_submission SET
diff=diff2, commit_ref=commit_ref2, pull_url=pull_url2,
delegate_id=delegate2_id, state_id=state2_id,
archived=archived2, hash=hash2
FROM patchwork_patch WHERE
patchwork_submission.id = patchwork_patch.submission_ptr_id
''',
""",
),
]
2 changes: 1 addition & 1 deletion patchwork/migrations/0020_tag_show_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Migration(migrations.Migration):
field=models.BooleanField(
default=True,
help_text=b"Show a column displaying this tag's count in the "
b"patch list view",
b'patch list view',
),
),
]
4 changes: 2 additions & 2 deletions patchwork/migrations/0024_patch_patch_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class Migration(migrations.Migration):
),
# as with 10, this will break if you use non-default table names
migrations.RunSQL(
'''UPDATE patchwork_patch SET patch_project_id =
"""UPDATE patchwork_patch SET patch_project_id =
(SELECT project_id FROM patchwork_submission
WHERE patchwork_submission.id =
patchwork_patch.submission_ptr_id);'''
patchwork_patch.submission_ptr_id);"""
),
migrations.AlterField(
model_name='patch',
Expand Down
4 changes: 2 additions & 2 deletions patchwork/migrations/0035_project_list_archive_url_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class Migration(migrations.Migration):
field=models.CharField(
blank=True,
help_text=b"URL format for the list archive's Message-ID "
b"redirector. {} will be replaced by the "
b"Message-ID.",
b'redirector. {} will be replaced by the '
b'Message-ID.',
max_length=2000,
),
),
Expand Down
4 changes: 2 additions & 2 deletions patchwork/migrations/0041_python3.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class Migration(migrations.Migration):
field=models.CharField(
blank=True,
help_text="URL format for the list archive's Message-ID "
"redirector. {} will be replaced by the Message-ID.",
'redirector. {} will be replaced by the Message-ID.',
max_length=2000,
),
),
Expand Down Expand Up @@ -314,7 +314,7 @@ class Migration(migrations.Migration):
field=models.BooleanField(
default=True,
help_text="Show a column displaying this tag's count in the "
"patch list view",
'patch list view',
),
),
migrations.AlterField(
Expand Down
12 changes: 6 additions & 6 deletions patchwork/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Project(models.Model):
max_length=2000,
blank=True,
help_text="URL format for the list archive's Message-ID redirector. "
"{} will be replaced by the Message-ID.",
'{} will be replaced by the Message-ID.',
)
commit_url_format = models.CharField(
max_length=2000,
Expand Down Expand Up @@ -270,7 +270,7 @@ class Tag(models.Model):
)
show_column = models.BooleanField(
help_text='Show a column displaying this'
' tag\'s count in the patch list view',
" tag's count in the patch list view",
default=True,
)

Expand Down Expand Up @@ -319,10 +319,10 @@ def with_tag_counts(self, project=None):

for tag in tags:
select[tag.attr_name] = (
"coalesce("
"(SELECT count FROM patchwork_patchtag"
" WHERE patchwork_patchtag.patch_id=patchwork_patch.id"
" AND patchwork_patchtag.tag_id=%s), 0)"
'coalesce('
'(SELECT count FROM patchwork_patchtag'
' WHERE patchwork_patchtag.patch_id=patchwork_patch.id'
' AND patchwork_patchtag.tag_id=%s), 0)'
)
select_params.append(tag.id)

Expand Down
12 changes: 6 additions & 6 deletions patchwork/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def find_project(mail, list_id=None):

if not project:
logger.debug(
"Could not find a valid project for given list-id and " "subject."
'Could not find a valid project for given list-id and ' 'subject.'
)

return project
Expand Down Expand Up @@ -412,7 +412,7 @@ def get_original_sender(mail, name, email):
cc_headers = mail.get_all('Cc') or []
for header in reply_to_headers + cc_headers:
header = clean_header(header)
addrs = header.split(",")
addrs = header.split(',')
for addr in addrs:
new_name, new_email = split_from_header(addr)
if new_name:
Expand Down Expand Up @@ -520,8 +520,8 @@ def find_message_id(mail):
# about this
logger.info(
"Malformed 'Message-Id' header. The 'msg-id' component should be "
"surrounded by angle brackets. Saving raw header. This may "
"include comments and extra whitespace."
'surrounded by angle brackets. Saving raw header. This may '
'include comments and extra whitespace.'
)
msgid = header.strip()

Expand All @@ -547,8 +547,8 @@ def find_references(mail):
else:
logger.info(
"Malformed 'In-Reply-To' header. The 'msg-id' component "
"should be surrounded by angle brackets. Saving raw header. "
"This may include comments and extra whitespace."
'should be surrounded by angle brackets. Saving raw header. '
'This may include comments and extra whitespace.'
)
ref = header.strip()
refs.append(ref)
Expand Down
2 changes: 1 addition & 1 deletion patchwork/templatetags/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def patch_tags(patch):
count = getattr(patch, tag.attr_name)
titles.append('%d %s' % (count, tag.name))
if count == 0:
counts.append("-")
counts.append('-')
else:
counts.append(str(count))

Expand Down
8 changes: 4 additions & 4 deletions patchwork/tests/api/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,18 +202,18 @@ def test_order_by_date_default(self):
self._create_events()

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

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

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

def test_create(self):
"""Ensure creates aren't allowed"""
Expand Down
4 changes: 2 additions & 2 deletions patchwork/tests/api/test_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _create_patch(self, **kwargs):
state=state_obj,
project=project_obj,
submitter=person_obj,
**kwargs
**kwargs,
)

return patch_obj
Expand Down Expand Up @@ -366,7 +366,7 @@ def test_update_maintainer_version_1_0(self):

self.client.force_authenticate(user=user)
resp = self.client.patch(
self.api_url(patch.id, version="1.1"),
self.api_url(patch.id, version='1.1'),
{'state': state.slug, 'delegate': user.id},
)
self.assertEqual(status.HTTP_200_OK, resp.status_code, resp)
Expand Down
Loading

0 comments on commit b4a21c0

Please sign in to comment.