Browse Source

working on adding linting and isort on CI

David Burke 3 years ago
parent
commit
055e638728

+ 9 - 0
.gitlab-ci.yml

@@ -31,6 +31,15 @@ test:
     - poetry install --no-interaction --no-ansi
     - ./manage.py test
 
+lint:
+  image: python:3.9-slim
+  script:
+    - apt-get update && apt-get install -y gcc
+    - pip install poetry
+    - poetry install --no-interaction --no-ansi
+    - isort --check glitchtip
+    - pylint --load-plugins=pylint_django --django-settings-module=glitchtip.settings --disable=R glitchtip
+
 build:
   image: docker:20
   rules:

+ 4 - 0
.pylintrc

@@ -1,3 +1,7 @@
 [MASTER]
 disable=
     C0114, # missing-module-docstring
+    missing-class-docstring,
+    missing-function-docstring,
+    abstract-method,
+    unused-argument

+ 3 - 1
.vscode/settings.json

@@ -2,10 +2,12 @@
   "python.formatting.provider": "black",
   "python.linting.pylintArgs": [
     "--enable=W0614",
+    "--django-settings-module=glitchtip.settings",
     "--load-plugins",
     "pylint_django"
   ],
   "python.linting.enabled": true,
   "python.linting.pylintEnabled": true,
-  "editor.formatOnSave": true
+  "editor.formatOnSave": true,
+  "files.trimTrailingWhitespace": true
 }

+ 2 - 1
glitchtip/authentication.py

@@ -1,6 +1,7 @@
 from django.utils.translation import gettext_lazy as _
-from rest_framework.authentication import TokenAuthentication
 from rest_framework import exceptions
+from rest_framework.authentication import TokenAuthentication
+
 from api_tokens.models import APIToken
 
 

+ 1 - 0
glitchtip/celery.py

@@ -19,4 +19,5 @@ app.autodiscover_tasks()
 
 @app.task(bind=True)
 def debug_task(self):
+    # pylint: disable=consider-using-f-string
     print("Request: {0!r}".format(self.request))

+ 2 - 3
glitchtip/debounced_celery_task.py

@@ -1,5 +1,6 @@
 # Credit https://gist.github.com/pardo/19d672235bbef6fa793a
 import functools
+
 from django.core.cache import cache
 
 
@@ -32,9 +33,7 @@ def debounced_task(key_generator):
         def wrapper(**kwargs):
             func_args = kwargs.get("args", [])
             func_kwargs = kwargs.get("kwargs", {})
-            key = "{}.{}.{}".format(
-                func.__module__, func.__name__, key_generator(*func_args, **func_kwargs)
-            )
+            key = f"{func.__module__}.{func.__name__}.{key_generator(*func_args, **func_kwargs)}"
             cache.add(key, 0)
             call_count = cache.incr(key)
             func_kwargs.update({"key": key, "call_count": call_count})

+ 1 - 1
glitchtip/email.py

@@ -1,9 +1,9 @@
 from django.conf import settings
 from django.contrib.auth import get_user_model
 from django.core.mail import EmailMultiAlternatives
+from django.template.loader import render_to_string
 from django.views.generic.base import ContextMixin
 from django.views.generic.detail import SingleObjectMixin
-from django.template.loader import render_to_string
 
 User = get_user_model()
 

+ 0 - 1
glitchtip/exceptions.py

@@ -6,4 +6,3 @@ class ConflictException(exceptions.APIException):
     status_code = status.HTTP_409_CONFLICT
     default_detail = _("Already present!")
     default_code = "already_present"
-

+ 1 - 0
glitchtip/pagination.py

@@ -1,5 +1,6 @@
 import urllib.parse as urlparse
 from urllib.parse import parse_qs
+
 from rest_framework.pagination import CursorPagination
 from rest_framework.response import Response
 

+ 3 - 1
glitchtip/permissions.py

@@ -8,6 +8,8 @@ class ScopedPermission(BasePermission):
     Fall back to checking for user authentication
     """
 
+    scope_map = {}
+
     def get_allowed_scopes(self, request, view):
         try:
             return self.scope_map[request.method]
@@ -22,7 +24,7 @@ class ScopedPermission(BasePermission):
         return bool(request.user and request.user.is_authenticated)
 
     def get_user_scopes(self, obj, user):
-        pass
+        return set()
 
     def has_object_permission(self, request, view, obj):
         allowed_scopes = self.get_allowed_scopes(request, view)

Some files were not shown because too many files changed in this diff