From 55aff276657e316342cdbf08dbc6b84daa8f75c7 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Tue, 3 Sep 2024 00:28:56 +0300 Subject: [PATCH] Bump pre-commit linting tools and fix linting/formatting errors --- .pre-commit-config.yaml | 4 +-- docker-app/manage.py | 1 + docker-app/qfieldcloud/core/admin.py | 6 ++--- docker-app/qfieldcloud/core/exceptions.py | 6 ++--- .../qfieldcloud/core/permissions_utils.py | 21 +++++---------- docker-app/qfieldcloud/core/utils2/storage.py | 6 ++--- docker-app/qfieldcloud/notifs/signals.py | 1 + .../qfieldcloud/subscription/exceptions.py | 6 ++--- docker-app/qfieldcloud/urls.py | 1 + docker-qgis/qfc_worker/utils.py | 27 +++++++++---------- 10 files changed, 35 insertions(+), 44 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dc62c0be4..19f610447 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: # Lint and format - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.6.2 + rev: v0.6.3 hooks: # Run the linter. - id: ruff @@ -23,7 +23,7 @@ repos: # Static type-checking with mypy - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v1.11.1' + rev: 'v1.11.2' hooks: - id: mypy additional_dependencies: [types-pytz, types-Deprecated, types-PyYAML, types-requests, types-tabulate, types-jsonschema, django-stubs, django-stubs-ext] diff --git a/docker-app/manage.py b/docker-app/manage.py index f6cc4ae7f..89e595224 100644 --- a/docker-app/manage.py +++ b/docker-app/manage.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Django's command-line utility for administrative tasks.""" + import sys diff --git a/docker-app/qfieldcloud/core/admin.py b/docker-app/qfieldcloud/core/admin.py index 68ac1eb9d..c87c6ca6a 100644 --- a/docker-app/qfieldcloud/core/admin.py +++ b/docker-app/qfieldcloud/core/admin.py @@ -646,9 +646,9 @@ def clean(self): if name and not name.startswith( pg_service_file.PGSERVICE_SECRET_NAME_PREFIX ): - cleaned_data[ - "name" - ] = f"{pg_service_file.PGSERVICE_SECRET_NAME_PREFIX}{name}" + cleaned_data["name"] = ( + f"{pg_service_file.PGSERVICE_SECRET_NAME_PREFIX}{name}" + ) return cleaned_data diff --git a/docker-app/qfieldcloud/core/exceptions.py b/docker-app/qfieldcloud/core/exceptions.py index 92ee05a32..74c3984a3 100644 --- a/docker-app/qfieldcloud/core/exceptions.py +++ b/docker-app/qfieldcloud/core/exceptions.py @@ -1,12 +1,10 @@ from rest_framework import status -class QfcError(Exception): - ... +class QfcError(Exception): ... -class IntegrationError(QfcError): - ... +class IntegrationError(QfcError): ... class QFieldCloudException(Exception): diff --git a/docker-app/qfieldcloud/core/permissions_utils.py b/docker-app/qfieldcloud/core/permissions_utils.py index c3cd5e784..17bbc9643 100644 --- a/docker-app/qfieldcloud/core/permissions_utils.py +++ b/docker-app/qfieldcloud/core/permissions_utils.py @@ -22,32 +22,25 @@ from qfieldcloud.subscription.models import Subscription -class CheckPermError(Exception): - ... +class CheckPermError(Exception): ... -class AlreadyCollaboratorError(CheckPermError): - ... +class AlreadyCollaboratorError(CheckPermError): ... -class ReachedCollaboratorLimitError(CheckPermError): - ... +class ReachedCollaboratorLimitError(CheckPermError): ... -class UserHasProjectRoleOrigins(CheckPermError): - ... +class UserHasProjectRoleOrigins(CheckPermError): ... -class UserOrganizationRoleError(CheckPermError): - ... +class UserOrganizationRoleError(CheckPermError): ... -class TeamOrganizationRoleError(CheckPermError): - ... +class TeamOrganizationRoleError(CheckPermError): ... -class ExpectedPremiumUserError(CheckPermError): - ... +class ExpectedPremiumUserError(CheckPermError): ... def user_eq(user1: QfcUser, user2: QfcUser) -> bool: diff --git a/docker-app/qfieldcloud/core/utils2/storage.py b/docker-app/qfieldcloud/core/utils2/storage.py index fc8fc552b..16880a740 100644 --- a/docker-app/qfieldcloud/core/utils2/storage.py +++ b/docker-app/qfieldcloud/core/utils2/storage.py @@ -214,9 +214,9 @@ def file_response( if https_port == settings.WEB_HTTPS_PORT and not settings.IN_TEST_SUITE: if as_attachment: extra_params["ResponseContentType"] = "application/force-download" - extra_params[ - "ResponseContentDisposition" - ] = f'attachment;filename="{filename}"' + extra_params["ResponseContentDisposition"] = ( + f'attachment;filename="{filename}"' + ) url = qfieldcloud.core.utils.get_s3_client().generate_presigned_url( "get_object", diff --git a/docker-app/qfieldcloud/notifs/signals.py b/docker-app/qfieldcloud/notifs/signals.py index 6d353da00..ed21fab21 100644 --- a/docker-app/qfieldcloud/notifs/signals.py +++ b/docker-app/qfieldcloud/notifs/signals.py @@ -1,6 +1,7 @@ """ This module logs activity streams using the `django-activity-stream` package. """ + from django.db.models.signals import post_save, pre_delete from django.dispatch import receiver from django_currentuser.middleware import get_current_authenticated_user diff --git a/docker-app/qfieldcloud/subscription/exceptions.py b/docker-app/qfieldcloud/subscription/exceptions.py index 76e1c3d38..cfa48b871 100644 --- a/docker-app/qfieldcloud/subscription/exceptions.py +++ b/docker-app/qfieldcloud/subscription/exceptions.py @@ -2,12 +2,10 @@ from rest_framework import status -class SubscriptionException(QFieldCloudException): - ... +class SubscriptionException(QFieldCloudException): ... -class NotPremiumPlanException(SubscriptionException): - ... +class NotPremiumPlanException(SubscriptionException): ... class ReachedMaxOrganizationMembersError(SubscriptionException): diff --git a/docker-app/qfieldcloud/urls.py b/docker-app/qfieldcloud/urls.py index 66680429f..0661aac20 100644 --- a/docker-app/qfieldcloud/urls.py +++ b/docker-app/qfieldcloud/urls.py @@ -16,6 +16,7 @@ 2. Add a URL to urlpatterns: path( 'blog/', include('blog.urls')) """ + from django.conf import settings from django.contrib import admin from django.urls import include, path, re_path diff --git a/docker-qgis/qfc_worker/utils.py b/docker-qgis/qfc_worker/utils.py index e3ee725c6..990bc367b 100644 --- a/docker-qgis/qfc_worker/utils.py +++ b/docker-qgis/qfc_worker/utils.py @@ -407,8 +407,7 @@ def list_local_files(project_id: str, project_dir: Path): ) -class WorkflowValidationException(Exception): - ... +class WorkflowValidationException(Exception): ... class Workflow: @@ -810,18 +809,18 @@ def get_layers_data(project: QgsProject) -> dict[str, dict]: if data_provider_error.messageList() else "" ) - layers_by_id[layer_id][ - "provider_error_message" - ] = data_provider_error.message() + layers_by_id[layer_id]["provider_error_message"] = ( + data_provider_error.message() + ) layers_by_id[layer_id]["provider_name"] = data_provider.name() if not layers_by_id[layer_id]["provider_error_summary"]: service = data_provider.uri().service() if service: - layers_by_id[layer_id][ - "provider_error_summary" - ] = f'Unable to connect to service "{service}".' + layers_by_id[layer_id]["provider_error_summary"] = ( + f'Unable to connect to service "{service}".' + ) host = data_provider.uri().host() port = ( @@ -830,9 +829,9 @@ def get_layers_data(project: QgsProject) -> dict[str, dict]: else None ) if host and (is_localhost(host, port) or has_ping(host)): - layers_by_id[layer_id][ - "provider_error_summary" - ] = f'Unable to connect to host "{host}".' + layers_by_id[layer_id]["provider_error_summary"] = ( + f'Unable to connect to host "{host}".' + ) path = layer_source.metadata.get("path") if path and not os.path.exists(path): @@ -840,9 +839,9 @@ def get_layers_data(project: QgsProject) -> dict[str, dict]: else: layers_by_id[layer_id]["error_code"] = "missing_dataprovider" - layers_by_id[layer_id][ - "provider_error_summary" - ] = "No data provider available" + layers_by_id[layer_id]["provider_error_summary"] = ( + "No data provider available" + ) return layers_by_id