Skip to content

Commit

Permalink
Merged master into release
Browse files Browse the repository at this point in the history
  • Loading branch information
suricactus committed Sep 13, 2023
2 parents 9ebe709 + f6a6ec9 commit c99281d
Show file tree
Hide file tree
Showing 122 changed files with 303 additions and 333 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ on:
pull_request:

jobs:
check_format:
lint:
if: '! github.event.pull_request.draft'
name: Check code formatting
name: Lint code base
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
Expand All @@ -19,7 +19,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Check code formatting
- name: Pre-commit
uses: pre-commit/action@v3.0.0

test:
Expand Down
5 changes: 4 additions & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[mypy]
no_implicit_optional = False

disable_error_code = var-annotated

# Turn off mypy for all django migration packages via naming convention.
[mypy-*.migrations.*]
ignore_errors: True

# Turn off mypy for unit tests
[mypy-*.tests.*]
ignore_errors: True
18 changes: 8 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@


repos:
# Fix end of files
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -13,7 +11,7 @@ repos:

# Remove unused imports/variables
- repo: https://github.com/myint/autoflake
rev: v1.4
rev: v2.2.1
hooks:
- id: autoflake
args:
Expand All @@ -30,29 +28,29 @@ repos:

# Black formatting
- repo: https://github.com/psf/black
rev: "22.3.0"
rev: "23.7.0"
hooks:
- id: black

# tool to automatically upgrade syntax for newer versions of the language
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.10.1
hooks:
- id: pyupgrade
args: [--py37-plus]

# Lint files
- repo: https://github.com/pycqa/flake8
rev: "3.9.0"
rev: "6.1.0"
hooks:
- id: flake8
additional_dependencies: [flake8-match==1.0.0, flake8-walrus==1.1.0]

# Static type-checking with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.3.0'
rev: 'v1.5.1'
hooks:
- id: mypy
additional_dependencies: [types-pytz, types-Deprecated, types-PyYAML, types-requests, types-redis, types-tabulate, types-jsonschema, django-stubs]
pass_filenames: false
files: ^docker-qgis/
entry: bash -c 'mypy -p docker-qgis "$@"' --
entry: bash -c 'mypy -p docker-qgis -p docker-app -p docker-redis "$@"' --
2 changes: 1 addition & 1 deletion docker-app/qfieldcloud/authentication/auth_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_user(self, user_id):
"""Almost the same as `contrib.auth.backends.ModelBackend`, but not using the default manager, but the normal `objects` manager
Returns:
Optional[Union[Person, Organization, Team]]: In theory it can return any of this three types, however it will always be a Person or None
Person | Organization | Team | None: In theory it can return any of these types, however it will always be a `Person` or `None`
"""
UserModel = get_user_model()

Expand Down
4 changes: 1 addition & 3 deletions docker-app/qfieldcloud/authentication/authentication.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
from typing import Type

from django.contrib.auth import get_user_model
from django.http.request import HttpRequest
from django.utils import timezone
from django.utils.translation import gettext as _
from qfieldcloud.core.models import User
from rest_framework import exceptions
from rest_framework.authentication import (
TokenAuthentication as DjangoRestFrameworkTokenAuthentication,
)

from .models import AuthToken

User = get_user_model()


def invalidate_all_tokens(user: User) -> int:
now = timezone.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("authentication", "0001_initial"),
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from datetime import datetime

from django.utils.timezone import datetime, now
from django.utils.timezone import now
from qfieldcloud.authentication.models import AuthToken
from qfieldcloud.core.models import Organization, Person, Team
from qfieldcloud.core.tests.utils import setup_subscription_plans
Expand Down
1 change: 0 additions & 1 deletion docker-app/qfieldcloud/core/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def clean_username(self, username, shallow=False):
if Person.objects.filter(
**{f"{username_field}__iexact": username},
).exists():

error_message = Person._meta.get_field(
username_field
).error_messages.get("unique")
Expand Down
Loading

0 comments on commit c99281d

Please sign in to comment.