Skip to content

Commit f9c99af

Browse files
committed
Lint
1 parent 1dac366 commit f9c99af

File tree

225 files changed

+519
-452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+519
-452
lines changed

fabfile.py

+23-52
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import datetime
22
import os
3-
import subprocess
43
from shlex import quote
4+
import subprocess
55

66
from invoke import run as local
77
from invoke.tasks import task
88

9+
910
# Process .env file
1011
if os.path.exists(".env"):
1112
with open(".env") as f:
@@ -137,15 +138,11 @@ def psql(c, command=None):
137138
@task
138139
def delete_docker_database(c, local_database_name=LOCAL_DATABASE_NAME):
139140
dexec(
140-
"dropdb --if-exists --host db --username={project_name} {database_name}".format(
141-
project_name=PROJECT_NAME, database_name=LOCAL_DATABASE_NAME
142-
),
141+
f"dropdb --if-exists --host db --username={PROJECT_NAME} {LOCAL_DATABASE_NAME}",
143142
"db",
144143
)
145144
dexec(
146-
"createdb --host db --username={project_name} {database_name}".format(
147-
project_name=PROJECT_NAME, database_name=LOCAL_DATABASE_NAME
148-
),
145+
f"createdb --host db --username={PROJECT_NAME} {LOCAL_DATABASE_NAME}",
149146
"db",
150147
)
151148
psql(c, "CREATE SCHEMA heroku_ext;")
@@ -160,12 +157,8 @@ def import_data(c, database_filename):
160157
delete_docker_database(c)
161158
# Import the database file to the db container
162159
dexec(
163-
"pg_restore --clean --no-acl --if-exists --no-owner --host db \
164-
--username={project_name} -d {database_name} {database_filename}".format(
165-
project_name=PROJECT_NAME,
166-
database_name=LOCAL_DATABASE_NAME,
167-
database_filename=database_filename,
168-
),
160+
f"pg_restore --clean --no-acl --if-exists --no-owner --host db \
161+
--username={PROJECT_NAME} -d {LOCAL_DATABASE_NAME} {database_filename}",
169162
service="db",
170163
)
171164
print(
@@ -275,12 +268,8 @@ def delete_local_database(c, local_database_name=LOCAL_DATABASE_NAME):
275268

276269
def aws(c, command, aws_access_key_id, aws_secret_access_key):
277270
return local(
278-
"AWS_ACCESS_KEY_ID={access_key_id} AWS_SECRET_ACCESS_KEY={secret_key} "
279-
"aws {command}".format(
280-
access_key_id=aws_access_key_id,
281-
secret_key=aws_secret_access_key,
282-
command=command,
283-
)
271+
f"AWS_ACCESS_KEY_ID={aws_access_key_id} AWS_SECRET_ACCESS_KEY={aws_secret_access_key} "
272+
f"aws {command}"
284273
)
285274

286275

@@ -291,10 +280,7 @@ def pull_media_from_s3(
291280
aws_storage_bucket_name,
292281
local_media_dir=LOCAL_MEDIA_DIR,
293282
):
294-
aws_cmd = "s3 sync --delete s3://{bucket_name} {local_media}".format(
295-
bucket_name=aws_storage_bucket_name,
296-
local_media=local_media_dir,
297-
)
283+
aws_cmd = f"s3 sync --delete s3://{aws_storage_bucket_name} {local_media_dir}"
298284
aws(c, aws_cmd, aws_access_key_id, aws_secret_access_key)
299285

300286

@@ -318,11 +304,7 @@ def pull_images_from_s3(
318304
aws_storage_bucket_name,
319305
local_images_dir=LOCAL_IMAGES_DIR,
320306
):
321-
aws_cmd = (
322-
"s3 sync --delete s3://{bucket_name}/original_images {local_media}".format(
323-
bucket_name=aws_storage_bucket_name, local_media=local_images_dir
324-
)
325-
)
307+
aws_cmd = f"s3 sync --delete s3://{aws_storage_bucket_name}/original_images {local_images_dir}"
326308
aws(c, aws_cmd, aws_access_key_id, aws_secret_access_key)
327309
# The above command just syncs the original images, so we need to drop the wagtailimages_renditions
328310
# table so that the renditions will be re-created when requested on the local build.
@@ -351,18 +333,13 @@ def pull_database_from_heroku(c, app_instance, anonymise=False):
351333
datestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
352334

353335
local(
354-
"heroku pg:backups:download --output={dump_folder}/{datestamp}.dump --app {app}".format(
355-
app=app_instance, dump_folder=LOCAL_DUMP_DIR, datestamp=datestamp
356-
),
336+
f"heroku pg:backups:download --output={LOCAL_DUMP_DIR}/{datestamp}.dump --app {app_instance}",
357337
)
358338

359339
import_data(c, f"/app/{LOCAL_DUMP_DIR}/{datestamp}.dump")
360340

361341
local(
362-
"rm {dump_folder}/{datestamp}.dump".format(
363-
dump_folder=LOCAL_DUMP_DIR,
364-
datestamp=datestamp,
365-
),
342+
f"rm {LOCAL_DUMP_DIR}/{datestamp}.dump",
366343
)
367344

368345
if anonymise:
@@ -394,13 +371,9 @@ def make_bold(msg):
394371
def dellar_snapshot(c, filename):
395372
"""Snapshot the database, files will be stored in the db container"""
396373
dexec(
397-
"pg_dump -d {database_name} -U {database_username} > {filename}.psql".format(
398-
database_name=LOCAL_DATABASE_NAME,
399-
database_username=LOCAL_DATABASE_USERNAME,
400-
filename=filename,
401-
),
374+
f"pg_dump -d {LOCAL_DATABASE_NAME} -U {LOCAL_DATABASE_USERNAME} > {filename}.psql",
402375
service="db",
403-
),
376+
)
404377
print("Database snapshot created")
405378

406379

@@ -409,14 +382,12 @@ def dellar_restore(c, filename):
409382
"""Restore the database from a snapshot in the db container"""
410383
delete_docker_database(c)
411384

412-
dexec(
413-
"psql -U {database_username} -d {database_name} < {filename}.psql".format(
414-
database_name=LOCAL_DATABASE_NAME,
415-
database_username=LOCAL_DATABASE_USERNAME,
416-
filename=filename,
385+
(
386+
dexec(
387+
f"psql -U {LOCAL_DATABASE_USERNAME} -d {LOCAL_DATABASE_NAME} < {filename}.psql",
388+
service="db",
417389
),
418-
service="db",
419-
),
390+
)
420391
print("Database restored.")
421392

422393

@@ -426,10 +397,10 @@ def dellar_list(c):
426397
print("Database snapshots:")
427398
dexec(
428399
"""for f in *.psql; do
429-
printf ' - %s\n' "${f%.psql}"
430-
done""",
400+
printf ' - %s\n' "${f%.psql}"
401+
done""",
431402
service="db",
432-
),
403+
)
433404
print("Restore with `dellar-restore <snapshot>`")
434405

435406

@@ -439,7 +410,7 @@ def dellar_remove(c, filename):
439410
dexec(
440411
f"rm {filename}.psql",
441412
service="db",
442-
),
413+
)
443414
print(f"Snapshot {filename} removed")
444415

445416

gunicorn-conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Replace gunicorn's 'Server' HTTP header to avoid leaking info to attackers
22
import gunicorn
33

4+
45
gunicorn.SERVER_SOFTWARE = ""

manage.py

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

5+
56
if __name__ == "__main__":
67
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tbx.settings.production")
78

tbx/blog/factories.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import factory
22
import wagtail_factories
3+
34
from tbx.blog.models import BlogIndexPage, BlogPage
45
from tbx.core.factories import StoryBlockFactory
56

tbx/blog/feeds.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from .models import BlogPage
88

9+
910
# Main blog feed
1011

1112

tbx/blog/migrations/0001_initial.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22

33
from django.db import migrations, models
44
import django.db.models.deletion
5+
56
import modelcluster.fields
6-
import tbx.core.blocks
77
import wagtail.blocks
88
import wagtail.embeds.blocks
99
import wagtail.fields
1010
import wagtail.images.blocks
11+
1112
import wagtailmarkdown.blocks
1213
import wagtailmedia.blocks
1314

15+
import tbx.core.blocks
1416

15-
class Migration(migrations.Migration):
1617

18+
class Migration(migrations.Migration):
1719
initial = True
1820

1921
dependencies = [

tbx/blog/migrations/0002_remove_blogindexpage_call_to_action_and_more.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Generated by Django 4.2.9 on 2024-01-15 10:16
22

33
from django.db import migrations
4-
import tbx.core.blocks
4+
55
import wagtail.blocks
66
import wagtail.embeds.blocks
77
import wagtail.fields
88
import wagtail.images.blocks
9+
910
import wagtailmarkdown.blocks
1011
import wagtailmedia.blocks
1112

13+
import tbx.core.blocks
1214

13-
class Migration(migrations.Migration):
1415

16+
class Migration(migrations.Migration):
1517
dependencies = [
1618
("blog", "0001_initial"),
1719
]

tbx/blog/migrations/0003_add_new_image_block_to_body_streamfield.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# Generated by Django 4.2.9 on 2024-01-15 11:14
22

33
from django.db import migrations
4+
45
import wagtail.blocks
56
import wagtail.embeds.blocks
67
import wagtail.fields
78
import wagtail.images.blocks
9+
810
import wagtailmarkdown.blocks
911
import wagtailmedia.blocks
1012

1113

1214
class Migration(migrations.Migration):
13-
1415
dependencies = [
1516
("blog", "0002_remove_blogindexpage_call_to_action_and_more"),
1617
]

tbx/blog/migrations/0003_alter_blogpage_body.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Generated by Django 4.2.9 on 2024-01-15 12:25
22

33
from django.db import migrations
4-
import tbx.core.blocks
4+
55
import wagtail.blocks
66
import wagtail.embeds.blocks
77
import wagtail.fields
88
import wagtail.images.blocks
9+
910
import wagtailmarkdown.blocks
1011
import wagtailmedia.blocks
1112

13+
import tbx.core.blocks
1214

13-
class Migration(migrations.Migration):
1415

16+
class Migration(migrations.Migration):
1517
dependencies = [
1618
("blog", "0002_remove_blogindexpage_call_to_action_and_more"),
1719
]

tbx/blog/migrations/0004_alter_blogpage_body.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Generated by Django 4.2.9 on 2024-01-16 13:44
22

33
from django.db import migrations
4-
import tbx.core.blocks
4+
55
import wagtail.blocks
66
import wagtail.embeds.blocks
77
import wagtail.fields
88
import wagtail.images.blocks
9+
910
import wagtailmarkdown.blocks
1011
import wagtailmedia.blocks
1112

13+
import tbx.core.blocks
1214

13-
class Migration(migrations.Migration):
1415

16+
class Migration(migrations.Migration):
1517
dependencies = [
1618
("blog", "0003_alter_blogpage_body"),
1719
]

tbx/blog/migrations/0004_data_migration_aligned_and_wide_images.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Generated by Django 4.2.9 on 2024-01-15 11:15
22

33
from django.db import migrations
4+
45
from wagtail.blocks.migrations.migrate_operation import MigrateStreamData
56
from wagtail.blocks.migrations.operations import RenameStreamChildrenOperation
67

tbx/blog/migrations/0005_remove_aligned_and_wide_image_blocks_from_body_streamfield.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# Generated by Django 4.2.9 on 2024-01-15 11:53
22

33
from django.db import migrations
4+
45
import wagtail.blocks
56
import wagtail.embeds.blocks
67
import wagtail.fields
78
import wagtail.images.blocks
9+
810
import wagtailmarkdown.blocks
911
import wagtailmedia.blocks
1012

1113

1214
class Migration(migrations.Migration):
13-
1415
dependencies = [
1516
("blog", "0004_data_migration_aligned_and_wide_images"),
1617
]

tbx/blog/migrations/0006_merge_20240117_1530.py

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

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
98
("blog", "0004_alter_blogpage_body"),
109
("blog", "0005_remove_aligned_and_wide_image_blocks_from_body_streamfield"),

tbx/blog/migrations/0007_alter_blogpage_body.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# Generated by Django 4.2.9 on 2024-01-18 13:49
22

33
from django.db import migrations
4+
45
import wagtail.blocks
56
import wagtail.embeds.blocks
67
import wagtail.fields
78
import wagtail.images.blocks
9+
810
import wagtailmarkdown.blocks
911
import wagtailmedia.blocks
1012

1113

1214
class Migration(migrations.Migration):
13-
1415
dependencies = [
1516
("blog", "0006_merge_20240117_1530"),
1617
]

tbx/blog/migrations/0008_alter_blogpage_body.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# Generated by Django 4.2.9 on 2024-01-18 14:11
22

33
from django.db import migrations
4+
45
import wagtail.blocks
56
import wagtail.embeds.blocks
67
import wagtail.fields
78
import wagtail.images.blocks
89
import wagtail.snippets.blocks
10+
911
import wagtailmarkdown.blocks
1012
import wagtailmedia.blocks
1113

1214

1315
class Migration(migrations.Migration):
14-
1516
dependencies = [
1617
("blog", "0007_alter_blogpage_body"),
1718
]

tbx/blog/migrations/0009_delete_blogpagerelatedlink.py

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

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
98
("blog", "0008_alter_blogpage_body"),
109
]

0 commit comments

Comments
 (0)