Skip to content

Commit

Permalink
style(server): fix linting errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswpark committed Aug 1, 2024
1 parent 281f759 commit ce9b4e3
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 24 deletions.
6 changes: 4 additions & 2 deletions server/accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ class Migration(migrations.Migration):
"is_active",
models.BooleanField(
default=True,
help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
help_text="Designates whether this user should be treated as active. Unselect this instead of "
"deleting accounts.",
verbose_name="active",
),
),
Expand All @@ -115,7 +116,8 @@ class Migration(migrations.Migration):
"groups",
models.ManyToManyField(
blank=True,
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
help_text="The groups this user belongs to. A user will get all permissions granted to each "
"of their groups.",
related_name="user_set",
related_query_name="user",
to="auth.Group",
Expand Down
3 changes: 2 additions & 1 deletion server/accounts/migrations/0002_change_user_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from django.db import migrations


def change_user_type(apps, schema_editor):
def change_user_type(apps, _schema_editor):
# noinspection PyPep8Naming
ContentType = apps.get_model("contenttypes", "ContentType")
ct = ContentType.objects.filter(app_label="auth", model="user").first()
if ct:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class Migration(migrations.Migration):
name="contact_url",
field=models.URLField(
blank=True,
help_text="Where users should contact you.<br>Example: https://t.me/@example, mailto:john.appleseed@example.com ",
help_text="Where users should contact you.<br>Example: https://t.me/@example, "
"mailto:john.appleseed@example.com ",
),
),
migrations.AddField(
Expand Down
6 changes: 3 additions & 3 deletions server/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def variant_check(variant):
return WRONG_PARAMETER_RESPONSE


def x86_type_check(type):
type_codenames = [type.codename for type in X86Type.objects.all()]
if type not in type_codenames:
def x86_type_check(x86_type):
type_codenames = [x86_type.codename for x86_type in X86Type.objects.all()]
if x86_type not in type_codenames:
return WRONG_PARAMETER_RESPONSE
2 changes: 1 addition & 1 deletion server/config/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


@register()
def configuration_check(app_configs, **kwargs):
def configuration_check(_app_configs, **_kwargs):
errors = []
checked_keys = [
("SHIPPER_SECRET_KEY", "secret key"),
Expand Down
49 changes: 37 additions & 12 deletions server/core/migrations/0001_optimized.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ class Migration(migrations.Migration):
"photo",
models.URLField(
blank=True,
help_text="URL to image of device.<br>Preferably grab an image from <a href=\"https://www.gsmarena.com\" target=\"_blank\">GSMArena.</a><br>Example: 'https://fdn2.gsmarena.com/vv/bigpic/lg-nexus-5x-.jpg', 'https://fdn2.gsmarena.com/vv/bigpic/huawei-nexus-6p-.jpg'",
help_text="URL to image of device.<br>Preferably grab an image from <a "
'href="https://www.gsmarena.com" target="_blank">GSMArena.</a><br>Example: '
"'https://fdn2.gsmarena.com/vv/bigpic/lg-nexus-5x-.jpg', "
"'https://fdn2.gsmarena.com/vv/bigpic/huawei-nexus-6p-.jpg'",
),
),
(
Expand All @@ -66,7 +69,8 @@ class Migration(migrations.Migration):
"maintainers",
models.ManyToManyField(
blank=True,
help_text="Choose the maintainers working on this device. Multiple maintainers can be selected.<br>",
help_text="Choose the maintainers working on this device. Multiple maintainers can be "
"selected.<br>",
related_name="devices",
to=settings.AUTH_USER_MODEL,
),
Expand Down Expand Up @@ -110,23 +114,28 @@ class Migration(migrations.Migration):
(
"ssh_keyfile",
models.TextField(
help_text="SSH keyfile to connect with. Note that the SSH keyfiles must be placed in the ./ssh/ directory defined in the docker-compose file.<br>Example: ssh_key, id_rsa, etc.",
help_text="SSH keyfile to connect with. Note that the SSH keyfiles must be placed in the "
"./ssh/ directory defined in the docker-compose file.<br>Example: ssh_key, id_rsa, "
"etc.",
max_length=100,
verbose_name="SSH keyfile",
),
),
(
"upload_path",
models.TextField(
help_text="Path to upload to on the server.<br>Example: /home/frs/project/example/R/, /mnt/media/mirror/src/target/R/, etc.",
help_text="Path to upload to on the server.<br>Example: /home/frs/project/example/R/, "
"/mnt/media/mirror/src/target/R/, etc.",
max_length=100,
),
),
(
"enabled",
models.BooleanField(
default=True,
help_text="Whether this mirror instance is enabled or not. If disabled, builds will not be mirrored until the mirror instance is enabled again and a background refresh task runs.",
help_text="Whether this mirror instance is enabled or not. If disabled, builds will not be "
"mirrored until the mirror instance is enabled again and a background refresh task "
"runs.",
),
),
(
Expand All @@ -140,7 +149,8 @@ class Migration(migrations.Migration):
(
"ssh_host_fingerprint_type",
models.TextField(
help_text="SSH host fingerprint type. Get this with <code>ssh-keyscan hostname</code>.<br>Example: ssh-rsa, etc.",
help_text="SSH host fingerprint type. Get this with <code>ssh-keyscan "
"hostname</code>.<br>Example: ssh-rsa, etc.",
max_length=20,
verbose_name="SSH host fingerprint type",
),
Expand All @@ -149,7 +159,11 @@ class Migration(migrations.Migration):
"download_url_base",
models.TextField(
blank=True,
help_text="Base of downloads URL, should a download URL exist.<br>Example: if full URL to download is https://sourceforge.net/projects/demo/files/Q/sunfish/Bliss-v14.2-sunfish-OFFICIAL-gapps-20210425.zip/download, then the base URL is https://sourceforge.net/projects/demo/files/Q/{}/download",
help_text="Base of downloads URL, should a download URL exist.<br>Example: if full URL to "
"download is "
"https://sourceforge.net/projects/demo/files/Q/sunfish/Bliss-v14.2-sunfish-OFFICIAL"
"-gapps-20210425.zip/download, then the base URL is "
"https://sourceforge.net/projects/demo/files/Q/{}/download",
max_length=100,
verbose_name="Download URL base",
),
Expand All @@ -158,7 +172,9 @@ class Migration(migrations.Migration):
"downloadable",
models.BooleanField(
default=False,
help_text="Whether downloads from this mirror instance is possible or not. If disabled, this mirror will not be shown to users in the mirror list. Make sure to set the URL base field above if you enable this option!",
help_text="Whether downloads from this mirror instance is possible or not. If disabled, "
"this mirror will not be shown to users in the mirror list. Make sure to set the "
"URL base field above if you enable this option!",
),
),
(
Expand All @@ -173,14 +189,18 @@ class Migration(migrations.Migration):
"priority",
models.IntegerField(
default=10,
help_text="Sets the priority of the mirror in the mirror list. Lower values will be listed first, and higher values will be listed last.<br>Note: the main server does not have a priority value and will always be the first in the mirror list.",
help_text="Sets the priority of the mirror in the mirror list. Lower values will be listed "
"first, and higher values will be listed last.<br>Note: the main server does not "
"have a priority value and will always be the first in the mirror list.",
),
),
(
"target_versions",
models.TextField(
blank=True,
help_text='Build versions to mirror to this server. Specify multiple versions on each line.<br>Wildcards are supported with the "*" character.<br>Example: *, v12.*, v12.5, ...',
help_text="Build versions to mirror to this server. Specify multiple versions on each "
'line.<br>Wildcards are supported with the "*" character.<br>Example: *, v12.*, '
"v12.5, ...",
max_length=100,
verbose_name="Target versions",
),
Expand Down Expand Up @@ -254,7 +274,9 @@ class Migration(migrations.Migration):
"mirrored_on",
models.ManyToManyField(
blank=True,
help_text="Servers this build is mirrored on. Do NOT edit manually.<br>Incorrectly modifying this field may result in mirror servers showing for a given build, even if the build is not mirrored on said mirror server.",
help_text="Servers this build is mirrored on. Do NOT edit manually.<br>Incorrectly modifying "
"this field may result in mirror servers showing for a given build, even if the "
"build is not mirrored on said mirror server.",
related_name="builds",
to="core.mirrorserver",
),
Expand All @@ -263,7 +285,10 @@ class Migration(migrations.Migration):
"enabled",
models.BooleanField(
default=True,
help_text="Whether this build is enabled or not. Disabled builds will not show up to users, or in the updater API until it is enabled again. Disabled builds are still replicated to mirror servers, so a user downloading from a mirror server may see the build listed.",
help_text="Whether this build is enabled or not. Disabled builds will not show up to users, "
"or in the updater API until it is enabled again. Disabled builds are still "
"replicated to mirror servers, so a user downloading from a mirror server may see "
"the build listed.",
),
),
("build_date", models.DateField(help_text="Build date")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Migration(migrations.Migration):
name="photo",
field=models.FileField(
blank=True,
help_text="Photo file of device. If blank, the server will try and download the photo in the `photo_url` field.",
help_text="Photo file of device. If blank, the server will try and download the photo in the "
"`photo_url` field.",
upload_to=core.models.Device.get_image_upload_path,
),
),
Expand All @@ -24,7 +25,8 @@ class Migration(migrations.Migration):
name="photo_thumbhash",
field=models.TextField(
blank=True,
help_text="Thumbhash of device photo. If blank, the server will try and regenerate it from the photo in the `photo` field.",
help_text="Thumbhash of device photo. If blank, the server will try and regenerate it from the photo "
"in the `photo` field.",
),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class Migration(migrations.Migration):
name="legacy_connection_mode",
field=models.BooleanField(
default=False,
help_text="Disables certain SSH key verification algorithms. We recommend leaving this unchecked unless something goes wrong during the verification process.",
help_text="Disables certain SSH key verification algorithms. We recommend leaving this unchecked "
"unless something goes wrong during the verification process.",
),
),
]
1 change: 1 addition & 0 deletions server/core/migrations/0009_variant_from_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


def create_variants(apps, _):
# noinspection PyPep8Naming
Variant = apps.get_model("core", "Variant")
try:
variant_data_from_config = ast.literal_eval(config.SHIPPER_UPLOAD_VARIANTS)
Expand Down
2 changes: 2 additions & 0 deletions server/core/migrations/0012_variant_data_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@


def update_build_variant(apps, _):
# noinspection PyPep8Naming
Build = apps.get_model("core", "Build")
# noinspection PyPep8Naming
Variant = apps.get_model("core", "Variant")

for build in Build.objects.all():
Expand Down
3 changes: 2 additions & 1 deletion server/core/migrations/0016_x86type_remove_build_x86_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class Migration(migrations.Migration):
(
"description",
models.TextField(
help_text="Description of the x86 text, as seen by users<br> Example: 'GO builds', 'Bass builds'",
help_text="Description of the x86 text, as seen by users<br> Example: 'GO builds', "
"'Bass builds'",
max_length=30,
),
),
Expand Down

0 comments on commit ce9b4e3

Please sign in to comment.