Skip to content

Commit

Permalink
Upgrade flake8 (#1356)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsmkn committed May 12, 2020
1 parent 2356d50 commit d4985d6
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -13,7 +13,7 @@ repos:
- id: black
language: python
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
rev: 3.8.0
hooks:
- id: flake8
language: python
Expand Down
6 changes: 3 additions & 3 deletions app/grandchallenge/algorithms/models.py
Expand Up @@ -42,13 +42,13 @@ class Algorithm(UUIDModel, TitleSlugDescriptionModel):
Group,
on_delete=models.CASCADE,
editable=False,
related_name=f"editors_of_algorithm",
related_name="editors_of_algorithm",
)
users_group = models.OneToOneField(
Group,
on_delete=models.CASCADE,
editable=False,
related_name=f"users_of_algorithm",
related_name="users_of_algorithm",
)
logo = models.ImageField(
upload_to=get_logo_path, storage=public_s3_storage
Expand Down Expand Up @@ -538,7 +538,7 @@ def remove_method(self):
@property
def permission_list_url(self):
return reverse(
f"algorithms:permission-request-list",
"algorithms:permission-request-list",
kwargs={"slug": self.base_object.slug},
)

Expand Down
2 changes: 1 addition & 1 deletion app/grandchallenge/archives/models.py
Expand Up @@ -240,7 +240,7 @@ def remove_method(self):
@property
def permission_list_url(self):
return reverse(
f"archives:permission-request-list",
"archives:permission-request-list",
kwargs={"slug": self.base_object.slug},
)

Expand Down
2 changes: 1 addition & 1 deletion app/grandchallenge/cases/image_builders/metaio_utils.py
Expand Up @@ -286,7 +286,7 @@ def add_additional_mh_headers_to_sitk_image(
if header in cleaned_headers:
value = cleaned_headers[header]
if isinstance(value, (list, tuple)):
value = " ".format([str(v) for v in value])
value = " ".join([str(v) for v in value])
else:
value = str(value)
sitk_image.SetMetaData(header, value)
Expand Down
2 changes: 1 addition & 1 deletion app/grandchallenge/cases/image_builders/tiff.py
Expand Up @@ -87,7 +87,7 @@ def _get_voxel_spacing_mm(tags, tag):
f"Invalid resolution unit {resolution_unit}" f" in tiff file"
)
except (ZeroDivisionError, TypeError, IndexError):
raise ValidationError(f"Invalid resolution in tiff file")
raise ValidationError("Invalid resolution in tiff file")


def _extract_openslide_properties(
Expand Down
4 changes: 2 additions & 2 deletions app/grandchallenge/cases/serializers.py
Expand Up @@ -91,7 +91,7 @@ def validate_algorithm_image(self, value):

if not user.has_perm("execute_algorithm", value.algorithm):
raise ValidationError(
f"User does not have permission to execute this algorithm"
"User does not have permission to execute this algorithm"
)

return value
Expand Down Expand Up @@ -145,7 +145,7 @@ def validate_upload_session(self, value):

if not user.has_perm("change_rawimageuploadsession", value):
raise ValidationError(
f"User does not have permission to change this raw image upload session"
"User does not have permission to change this raw image upload session"
)

return value
Expand Down
6 changes: 3 additions & 3 deletions app/grandchallenge/container_exec/backends/docker.py
Expand Up @@ -224,7 +224,7 @@ def _chmod_volumes(self):
self._output_volume: {"bind": "/output/", "mode": "rw"},
},
name=f"{self._job_label}-chmod-volumes",
command=f"chmod -R 0777 /input/ /output/",
command="chmod -R 0777 /input/ /output/",
remove=True,
labels=self._labels,
**self._run_kwargs,
Expand Down Expand Up @@ -362,13 +362,13 @@ def start(
"traefik.enable": "true",
f"traefik.http.routers.{hostname}-http.rule": f"Host(`{hostname}`)",
f"traefik.http.routers.{hostname}-http.service": f"{hostname}-http",
f"traefik.http.routers.{hostname}-http.entrypoints": f"workstation-http",
f"traefik.http.routers.{hostname}-http.entrypoints": "workstation-http",
f"traefik.http.services.{hostname}-http.loadbalancer.server.port": str(
http_port
),
f"traefik.http.routers.{hostname}-websocket.rule": f"Host(`{hostname}`)",
f"traefik.http.routers.{hostname}-websocket.service": f"{hostname}-websocket",
f"traefik.http.routers.{hostname}-websocket.entrypoints": f"workstation-websocket",
f"traefik.http.routers.{hostname}-websocket.entrypoints": "workstation-websocket",
f"traefik.http.services.{hostname}-websocket.loadbalancer.server.port": str(
websocket_port
),
Expand Down
8 changes: 5 additions & 3 deletions app/grandchallenge/datasets/models.py
Expand Up @@ -125,7 +125,7 @@ def label_index(self) -> dict:

try:
common_prefix = commonprefix(
[str(l[join_key]).lower() for l in self.labels]
[str(label[join_key]).lower() for label in self.labels]
)
except KeyError:
logger.warning(
Expand All @@ -135,8 +135,10 @@ def label_index(self) -> dict:
return {}

return {
find_first_int(instr=str(l[join_key])[len(common_prefix) :]): l
for l in self.labels
find_first_int(
instr=str(label[join_key])[len(common_prefix) :]
): label
for label in self.labels
}

@property
Expand Down
2 changes: 1 addition & 1 deletion app/grandchallenge/evaluation/models.py
Expand Up @@ -437,7 +437,7 @@ def _copy_input_files(self, writer):

# Remove a duplicated directory
input_files = (
writer.exec_run(f"ls -1 /input/")
writer.exec_run("ls -1 /input/")
.output.decode()
.splitlines()
)
Expand Down
2 changes: 1 addition & 1 deletion app/grandchallenge/pages/substitutions.py
Expand Up @@ -36,7 +36,7 @@ def __init__(
def pattern(self) -> str:
pattern = rf"{self._markers[0]}\s*{self._tag_name}"
if self._use_arg:
pattern += rf"\s+[\'\"]?([a-zA-Z0-9_\-]+)[\'\"]?"
pattern += r"\s+[\'\"]?([a-zA-Z0-9_\-]+)[\'\"]?"
pattern += rf"\s*{self._markers[1]}"
return pattern

Expand Down
6 changes: 3 additions & 3 deletions app/grandchallenge/reader_studies/models.py
Expand Up @@ -183,13 +183,13 @@ class ReaderStudy(UUIDModel, TitleSlugDescriptionModel):
Group,
on_delete=models.CASCADE,
editable=False,
related_name=f"editors_of_readerstudy",
related_name="editors_of_readerstudy",
)
readers_group = models.OneToOneField(
Group,
on_delete=models.CASCADE,
editable=False,
related_name=f"readers_of_readerstudy",
related_name="readers_of_readerstudy",
)
images = models.ManyToManyField(
"cases.Image", related_name="readerstudies"
Expand Down Expand Up @@ -1463,7 +1463,7 @@ def remove_method(self):
@property
def permission_list_url(self):
return reverse(
f"reader-studies:permission-request-list",
"reader-studies:permission-request-list",
kwargs={"slug": self.base_object.slug},
)

Expand Down
6 changes: 2 additions & 4 deletions app/grandchallenge/reader_studies/serializers.py
Expand Up @@ -105,12 +105,10 @@ def validate(self, attrs):
not self.instance.question.reader_study.allow_answer_modification
):
raise ValidationError(
f"This reader study does not allow answer modification."
"This reader study does not allow answer modification."
)
if list(attrs.keys()) != ["answer"]:
raise ValidationError(
f"Only the answer field can be modified."
)
raise ValidationError("Only the answer field can be modified.")
question = self.instance.question
images = self.instance.images.all()
creator = self.instance.creator
Expand Down
Expand Up @@ -46,8 +46,8 @@ def handle(self, *args, **options):

if len(failed_ids) > 0:
self.stdout.write(
f"Done, but some images failed. IDs of failed images:"
"Done, but some images failed. IDs of failed images:"
)
self.stdout.writelines([str(uuid) for uuid in failed_ids])
else:
self.stdout.write(self.style.SUCCESS(f"Finished successfully!"))
self.stdout.write(self.style.SUCCESS("Finished successfully!"))
4 changes: 2 additions & 2 deletions app/tests/algorithms_tests/test_permissions.py
Expand Up @@ -180,7 +180,7 @@ def test_algorithm_results_list_view(client):

for test in tests:
response = get_view_for_user(
viewname=f"algorithms:results-list",
viewname="algorithms:results-list",
reverse_kwargs={"slug": test[1].slug},
client=client,
user=test[0],
Expand Down Expand Up @@ -245,7 +245,7 @@ def test_algorithm_execution_session_list_view(client):

for test in tests:
response = get_view_for_user(
viewname=f"algorithms:execution-session-list",
viewname="algorithms:execution-session-list",
reverse_kwargs={"slug": test[1].slug},
client=client,
user=test[0],
Expand Down
4 changes: 2 additions & 2 deletions app/tests/reader_studies_tests/test_forms.py
Expand Up @@ -754,8 +754,8 @@ def test_reader_study_add_ground_truth(client, settings):
in response.rendered_content
)
assert (
f"The following images appear in the file, but not in the hanging "
f"list: im5." in response.rendered_content
"The following images appear in the file, but not in the hanging "
"list: im5." in response.rendered_content
)
assert (
"These images appear in the hanging list, but not in the file: im4."
Expand Down
4 changes: 2 additions & 2 deletions app/tests/retina_api_tests/test_viewsets.py
Expand Up @@ -2171,7 +2171,7 @@ def perform_request(rf, user_type, querystring, data=None):

user = get_user_from_user_type(user_type, **kwargs)

url = reverse(f"api:retina-landmark-annotation-list") + querystring
url = reverse("api:retina-landmark-annotation-list") + querystring

request = rf.get(url)

Expand All @@ -2189,7 +2189,7 @@ def test_no_query_params(self, rf, user_type):

def test_invalid_image_uuid(self, rf, user_type):
response = self.perform_request(
rf, user_type, f"?image_id=invalid_uuid"
rf, user_type, "?image_id=invalid_uuid"
)

if user_type in (None, "normal_user"):
Expand Down
2 changes: 1 addition & 1 deletion app/tests/settings.py
Expand Up @@ -5,7 +5,7 @@
os.environ["PROTECTED_S3_CUSTOM_DOMAIN"] = "testserver/media"

# noinspection PyUnresolvedReferences
from config.settings import * # noqa: F401, F403
from config.settings import * # noqa: F401, F403, E402

""" Settings overrides for tests """

Expand Down

0 comments on commit d4985d6

Please sign in to comment.