Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump pre-commit linting tools and fix linting/formatting errors #1012

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions docker-app/manage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import sys


Expand Down
6 changes: 3 additions & 3 deletions docker-app/qfieldcloud/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 2 additions & 4 deletions docker-app/qfieldcloud/core/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from rest_framework import status


class QfcError(Exception):
...
class QfcError(Exception): ...


class IntegrationError(QfcError):
...
class IntegrationError(QfcError): ...


class QFieldCloudException(Exception):
Expand Down
21 changes: 7 additions & 14 deletions docker-app/qfieldcloud/core/permissions_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions docker-app/qfieldcloud/core/utils2/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions docker-app/qfieldcloud/notifs/signals.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions docker-app/qfieldcloud/subscription/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
from rest_framework import status


class SubscriptionException(QFieldCloudException):
...
class SubscriptionException(QFieldCloudException): ...


class NotPremiumPlanException(SubscriptionException):
...
class NotPremiumPlanException(SubscriptionException): ...


class ReachedMaxOrganizationMembersError(SubscriptionException):
Expand Down
1 change: 1 addition & 0 deletions docker-app/qfieldcloud/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 13 additions & 14 deletions docker-qgis/qfc_worker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ def list_local_files(project_id: str, project_dir: Path):
)


class WorkflowValidationException(Exception):
...
class WorkflowValidationException(Exception): ...


class Workflow:
Expand Down Expand Up @@ -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 = (
Expand All @@ -830,19 +829,19 @@ 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):
layers_by_id[layer_id]["error_summary"] = f'File "{path}" missing.'

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

Expand Down
Loading