Skip to content

Commit

Permalink
Upating docstring and fix noise
Browse files Browse the repository at this point in the history
  • Loading branch information
tdrivas committed Dec 22, 2024
1 parent 631e72a commit cb37469
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions docker-app/qfieldcloud/core/drf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class QfcOrderingFilter(filters.OrderingFilter):
TOKENS_LIST_SEPARATOR = ","
TOKENS_VALUE_SEPARATOR = "="

def _get_query_field(self, fields: list[str], term: str) -> str | None:
def _get_query_field(self, fields: Iterable[str], term: str) -> str | None:
"""Searches a term in a query field list.
The field list elements may start with "-".
Expand Down Expand Up @@ -88,8 +88,8 @@ def remove_invalid_fields(
Args:
queryset (QuerySet): Django's ORM queryset of the same model as the one used in view of the `ModelViewSet`
fields (list[str]): ordering fields passed to the HTTP querystring
view (ModelViewSet): DRF view instance
fields (Iterable[str]): ordering fields passed to the HTTP querystring
view (APIView): DRF view instance
request (HttpRequest): DRF request instance
Returns :
list[str]: parsed ordering fields where aliases have been replaced
Expand All @@ -114,7 +114,7 @@ def remove_invalid_fields(

definition_name, attrs = self._parse_definition(field_name)
alias = attrs.get("alias", definition_name)
query_field_name = self._get_query_field(list(fields), alias)
query_field_name = self._get_query_field(fields, alias)

# field is not in the HTTP GET request querystring
if not query_field_name:
Expand Down
3 changes: 1 addition & 2 deletions docker-app/qfieldcloud/core/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Optional
from rest_framework import status


Expand All @@ -22,7 +21,7 @@ class QFieldCloudException(Exception):

code = "unknown_error"
message = "QFieldcloud Unknown Error"
status_code: Optional[int] = None
status_code: int | None = None
log_as_error = True

def __init__(self, detail="", status_code=None):
Expand Down
6 changes: 3 additions & 3 deletions docker-app/qfieldcloud/core/pagination.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from itertools import islice
from typing import Any, Callable, Optional
from typing import Any, Callable

from django.conf import settings
from rest_framework import pagination, response
Expand Down Expand Up @@ -35,12 +35,12 @@ def get_headers(self) -> dict[str, Any]:
"X-Total-Count": str(self.count),
}

next_link: Optional[str] = self.get_next_link()
next_link: str | None = self.get_next_link()

if next_link:
headers["X-Next-Page"] = next_link

previous_link: Optional[str] = self.get_previous_link()
previous_link: str | None = self.get_previous_link()
if previous_link:
headers["X-Previous-Page"] = previous_link

Expand Down

0 comments on commit cb37469

Please sign in to comment.