Skip to content

Commit b44a77d

Browse files
committed
trivial: Feed 'patchwork.migrations' through black
Include migrations in the flake8 checks, which should catch some simple undefined variables errors. Signed-off-by: Stephen Finucane <[email protected]>
1 parent 271d913 commit b44a77d

39 files changed

+991
-344
lines changed

patchwork/migrations/0001_initial.py

Lines changed: 302 additions & 75 deletions
Large diffs are not rendered by default.

patchwork/migrations/0002_fix_patch_state_default_values.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ class Migration(migrations.Migration):
1515
migrations.AlterField(
1616
model_name='patch',
1717
name='state',
18-
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='patchwork.State', null=True),
18+
field=models.ForeignKey(
19+
on_delete=django.db.models.deletion.CASCADE,
20+
to='patchwork.State',
21+
null=True,
22+
),
1923
),
2024
]

patchwork/migrations/0003_add_check_model.py

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,74 @@ class Migration(migrations.Migration):
1818
migrations.CreateModel(
1919
name='Check',
2020
fields=[
21-
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
21+
(
22+
'id',
23+
models.AutoField(
24+
verbose_name='ID',
25+
serialize=False,
26+
auto_created=True,
27+
primary_key=True,
28+
),
29+
),
2230
('date', models.DateTimeField(default=datetime.datetime.now)),
23-
('state', models.SmallIntegerField(default=0, help_text=b'The state of the check.', choices=[(0, b'pending'), (1, b'success'), (2, b'warning'), (3, b'fail')])),
24-
('target_url', models.URLField(help_text=b'The target URL to associate with this check. This should be specific to the patch.', null=True, blank=True)),
25-
('description', models.TextField(help_text=b'A brief description of the check.', null=True, blank=True)),
26-
('context', models.CharField(default=b'default', max_length=255, null=True, help_text=b'A label to discern check from checks of other testing systems.', blank=True)),
27-
('patch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='patchwork.Patch')),
28-
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
31+
(
32+
'state',
33+
models.SmallIntegerField(
34+
default=0,
35+
help_text=b'The state of the check.',
36+
choices=[
37+
(0, b'pending'),
38+
(1, b'success'),
39+
(2, b'warning'),
40+
(3, b'fail'),
41+
],
42+
),
43+
),
44+
(
45+
'target_url',
46+
models.URLField(
47+
help_text=b'The target URL to associate with this '
48+
b'check. This should be specific to the '
49+
b'patch.',
50+
null=True,
51+
blank=True,
52+
),
53+
),
54+
(
55+
'description',
56+
models.TextField(
57+
help_text=b'A brief description of the check.',
58+
null=True,
59+
blank=True,
60+
),
61+
),
62+
(
63+
'context',
64+
models.CharField(
65+
default=b'default',
66+
max_length=255,
67+
null=True,
68+
help_text=b'A label to discern check from checks of '
69+
b'other testing systems.',
70+
blank=True,
71+
),
72+
),
73+
(
74+
'patch',
75+
models.ForeignKey(
76+
on_delete=django.db.models.deletion.CASCADE,
77+
to='patchwork.Patch',
78+
),
79+
),
80+
(
81+
'user',
82+
models.ForeignKey(
83+
on_delete=django.db.models.deletion.CASCADE,
84+
to=settings.AUTH_USER_MODEL,
85+
),
86+
),
2987
],
30-
options={
31-
},
88+
options={},
3289
bases=(models.Model,),
3390
),
3491
]

patchwork/migrations/0004_add_delegation_rule_model.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,35 @@ class Migration(migrations.Migration):
1717
migrations.CreateModel(
1818
name='DelegationRule',
1919
fields=[
20-
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
20+
(
21+
'id',
22+
models.AutoField(
23+
verbose_name='ID',
24+
serialize=False,
25+
auto_created=True,
26+
primary_key=True,
27+
),
28+
),
2129
('path', models.CharField(max_length=255)),
2230
('priority', models.IntegerField(default=0)),
23-
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='patchwork.Project')),
24-
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
31+
(
32+
'project',
33+
models.ForeignKey(
34+
on_delete=django.db.models.deletion.CASCADE,
35+
to='patchwork.Project',
36+
),
37+
),
38+
(
39+
'user',
40+
models.ForeignKey(
41+
on_delete=django.db.models.deletion.CASCADE,
42+
to=settings.AUTH_USER_MODEL,
43+
),
44+
),
2545
],
26-
options={
27-
'ordering': ['-priority', 'path'],
28-
},
46+
options={'ordering': ['-priority', 'path']},
2947
),
3048
migrations.AlterUniqueTogether(
31-
name='delegationrule',
32-
unique_together=set([('path', 'project')]),
49+
name='delegationrule', unique_together=set([('path', 'project')]),
3350
),
3451
]

patchwork/migrations/0005_unselectable_maintainer_projects.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class Migration(migrations.Migration):
1414
migrations.AlterField(
1515
model_name='userprofile',
1616
name='maintainer_projects',
17-
field=models.ManyToManyField(related_name='maintainer_project', to='patchwork.Project', blank=True),
17+
field=models.ManyToManyField(
18+
related_name='maintainer_project',
19+
to='patchwork.Project',
20+
blank=True,
21+
),
1822
),
1923
]

patchwork/migrations/0006_add_patch_diff.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ class Migration(migrations.Migration):
1313

1414
operations = [
1515
migrations.RenameField(
16-
model_name='patch',
17-
old_name='content',
18-
new_name='diff',
16+
model_name='patch', old_name='content', new_name='diff',
1917
),
2018
migrations.AddField(
2119
model_name='patch',
@@ -29,6 +27,7 @@ class Migration(migrations.Migration):
2927
on_delete=django.db.models.deletion.CASCADE,
3028
related_query_name=b'comment',
3129
related_name='comments',
32-
to='patchwork.Patch'),
30+
to='patchwork.Patch',
31+
),
3332
),
3433
]

patchwork/migrations/0007_move_comment_content_to_patch_content.py

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@
66

77
def copy_comment_field(apps, schema_editor):
88
if connection.vendor == 'postgresql':
9-
schema_editor.execute('''
9+
schema_editor.execute(
10+
'''
1011
UPDATE patchwork_patch
1112
SET content = patchwork_comment.content
1213
FROM patchwork_comment
1314
WHERE patchwork_patch.id=patchwork_comment.patch_id
1415
AND patchwork_patch.msgid=patchwork_comment.msgid
15-
''')
16+
'''
17+
)
1618
elif connection.vendor == 'mysql':
17-
schema_editor.execute('''
19+
schema_editor.execute(
20+
'''
1821
UPDATE patchwork_patch, patchwork_comment
1922
SET patchwork_patch.content = patchwork_comment.content
2023
WHERE patchwork_patch.id=patchwork_comment.patch_id
2124
AND patchwork_patch.msgid=patchwork_comment.msgid
22-
''')
25+
'''
26+
)
2327
else:
2428
Comment = apps.get_model('patchwork', 'Comment')
2529
Patch = apps.get_model('patchwork', 'Patch')
@@ -39,19 +43,23 @@ def copy_comment_field(apps, schema_editor):
3943

4044
def remove_duplicate_comments(apps, schema_editor):
4145
if connection.vendor == 'postgresql':
42-
schema_editor.execute('''
46+
schema_editor.execute(
47+
'''
4348
DELETE FROM patchwork_comment
4449
USING patchwork_patch
4550
WHERE patchwork_patch.id=patchwork_comment.patch_id
4651
AND patchwork_patch.msgid=patchwork_comment.msgid
47-
''')
52+
'''
53+
)
4854
elif connection.vendor == 'mysql':
49-
schema_editor.execute('''
55+
schema_editor.execute(
56+
'''
5057
DELETE FROM patchwork_comment
5158
USING patchwork_patch, patchwork_comment
5259
WHERE patchwork_patch.id=patchwork_comment.patch_id
5360
AND patchwork_patch.msgid=patchwork_comment.msgid
54-
''')
61+
'''
62+
)
5563
else:
5664
Comment = apps.get_model('patchwork', 'Comment')
5765
Patch = apps.get_model('patchwork', 'Patch')
@@ -78,9 +86,14 @@ def recreate_comments(apps, schema_editor):
7886

7987
for patch in Patch.objects.all():
8088
if patch.content:
81-
comment = Comment(patch=patch, msgid=patch.msgid, date=patch.date,
82-
headers=patch.headers, submitter=patch.submitter,
83-
content=patch.content)
89+
comment = Comment(
90+
patch=patch,
91+
msgid=patch.msgid,
92+
date=patch.date,
93+
headers=patch.headers,
94+
submitter=patch.submitter,
95+
content=patch.content,
96+
)
8497
comment.save()
8598

8699

@@ -91,8 +104,10 @@ class Migration(migrations.Migration):
91104
]
92105

93106
operations = [
94-
migrations.RunPython(copy_comment_field, uncopy_comment_field,
95-
atomic=False),
96-
migrations.RunPython(remove_duplicate_comments, recreate_comments,
97-
atomic=False),
107+
migrations.RunPython(
108+
copy_comment_field, uncopy_comment_field, atomic=False
109+
),
110+
migrations.RunPython(
111+
remove_duplicate_comments, recreate_comments, atomic=False
112+
),
98113
]

patchwork/migrations/0009_add_submission_model.py

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,16 @@ class Migration(migrations.Migration):
1616

1717
operations = [
1818
# Rename the 'Patch' to 'Submission'
19-
migrations.RenameModel(
20-
old_name='Patch',
21-
new_name='Submission'
22-
),
19+
migrations.RenameModel(old_name='Patch', new_name='Submission'),
2320
migrations.AlterModelOptions(
24-
name='submission',
25-
options={'ordering': ['date']},
21+
name='submission', options={'ordering': ['date']},
2622
),
27-
2823
# Rename the non-Patch specific references to point to Submission
2924
migrations.RenameField(
30-
model_name='comment',
31-
old_name='patch',
32-
new_name='submission',
25+
model_name='comment', old_name='patch', new_name='submission',
3326
),
3427
migrations.AlterUniqueTogether(
35-
name='comment',
36-
unique_together=set([('msgid', 'submission')]),
28+
name='comment', unique_together=set([('msgid', 'submission')]),
3729
),
3830
migrations.RenameField(
3931
model_name='userprofile',
@@ -44,42 +36,68 @@ class Migration(migrations.Migration):
4436
model_name='userprofile',
4537
name='items_per_page',
4638
field=models.PositiveIntegerField(
47-
default=100,
48-
help_text=b'Number of items to display per page'),
39+
default=100, help_text=b'Number of items to display per page'
40+
),
4941
),
50-
5142
# Recreate the 'Patch' model as a subclass of 'Submission'. Each field
5243
# is given a unique name to prevent it conflicting with the same field
5344
# found in the 'Submission' "super model". We will fix this later.
5445
migrations.CreateModel(
5546
name='Patch',
5647
fields=[
57-
('submission_ptr', models.OneToOneField(
58-
parent_link=True, auto_created=True, primary_key=True,
59-
on_delete=django.db.models.deletion.CASCADE,
60-
serialize=False, to='patchwork.Submission')),
48+
(
49+
'submission_ptr',
50+
models.OneToOneField(
51+
parent_link=True,
52+
auto_created=True,
53+
primary_key=True,
54+
on_delete=django.db.models.deletion.CASCADE,
55+
serialize=False,
56+
to='patchwork.Submission',
57+
),
58+
),
6159
('diff2', models.TextField(null=True, blank=True)),
62-
('commit_ref2', models.CharField(
63-
max_length=255, null=True, blank=True)),
64-
('pull_url2', models.CharField(
65-
max_length=255, null=True, blank=True)),
60+
(
61+
'commit_ref2',
62+
models.CharField(max_length=255, null=True, blank=True),
63+
),
64+
(
65+
'pull_url2',
66+
models.CharField(max_length=255, null=True, blank=True),
67+
),
6668
# we won't migrate the data of this, seeing as it's
6769
# automatically recreated every time we save a Patch
68-
('tags2', models.ManyToManyField(
69-
to='patchwork.Tag', through='patchwork.PatchTag')),
70-
('delegate2', models.ForeignKey(
71-
on_delete=django.db.models.deletion.CASCADE,
72-
blank=True, to=settings.AUTH_USER_MODEL, null=True)),
73-
('state2', models.ForeignKey(
74-
on_delete=django.db.models.deletion.CASCADE,
75-
to='patchwork.State')),
70+
(
71+
'tags2',
72+
models.ManyToManyField(
73+
to='patchwork.Tag', through='patchwork.PatchTag'
74+
),
75+
),
76+
(
77+
'delegate2',
78+
models.ForeignKey(
79+
on_delete=django.db.models.deletion.CASCADE,
80+
blank=True,
81+
to=settings.AUTH_USER_MODEL,
82+
null=True,
83+
),
84+
),
85+
(
86+
'state2',
87+
models.ForeignKey(
88+
on_delete=django.db.models.deletion.CASCADE,
89+
to='patchwork.State',
90+
),
91+
),
7692
('archived2', models.BooleanField(default=False)),
77-
('hash2', patchwork.models.HashField(
78-
max_length=40, null=True, blank=True)),
93+
(
94+
'hash2',
95+
patchwork.models.HashField(
96+
max_length=40, null=True, blank=True
97+
),
98+
),
7999
],
80-
options={
81-
'verbose_name_plural': 'Patches',
82-
},
100+
options={'verbose_name_plural': 'Patches'},
83101
bases=('patchwork.submission',),
84102
),
85103
]

patchwork/migrations/0010_migrate_data_from_submission_to_patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ class Migration(migrations.Migration):
2525
archived=archived2, hash=hash2
2626
FROM patchwork_patch WHERE
2727
patchwork_submission.id = patchwork_patch.submission_ptr_id
28-
'''
28+
''',
2929
),
3030
]

0 commit comments

Comments
 (0)