From fa368a399a0931947334c436a927967346798912 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 3 Nov 2020 18:16:36 +0100 Subject: [PATCH] More linting --- apps/participation/tests.py | 6 +++--- corres2math/matrix.py | 11 +++++++---- corres2math/middlewares.py | 5 ++--- corres2math/settings.py | 7 +++---- corres2math/urls.py | 4 ++-- tox.ini | 4 ++-- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/apps/participation/tests.py b/apps/participation/tests.py index 4ce5822..21a3c43 100644 --- a/apps/participation/tests.py +++ b/apps/participation/tests.py @@ -562,10 +562,10 @@ class TestStudentParticipation(TestCase): reverse("participation:add_question", args=(self.team.participation.pk,)), 302, 200) response = self.client.get(reverse("participation:update_question", args=(self.question.pk,))) self.assertRedirects(response, reverse("login") + "?next=" + - reverse("participation:delete_question", args=(self.question.pk,)), 302, 200) - response = self.client.get(reverse("participation:add_question", args=(self.question.pk,))) + reverse("participation:update_question", args=(self.question.pk,)), 302, 200) + response = self.client.get(reverse("participation:delete_question", args=(self.question.pk,))) self.assertRedirects(response, reverse("login") + "?next=" + - reverse("participation:add_question", args=(self.question.pk,)), 302, 200) + reverse("participation:delete_question", args=(self.question.pk,)), 302, 200) def test_current_phase(self): """ diff --git a/corres2math/matrix.py b/corres2math/matrix.py index ddf76c6..9434baa 100644 --- a/corres2math/matrix.py +++ b/corres2math/matrix.py @@ -1,8 +1,12 @@ import os -from typing import Tuple +from typing import Any, Dict, Optional, Tuple, Union from asgiref.sync import async_to_sync -from nio import * +from nio import AsyncClient, DataProvider, ProfileSetAvatarError, ProfileSetAvatarResponse, \ + ProfileSetDisplayNameError, ProfileSetDisplayNameResponse, RoomCreateError, RoomCreateResponse, \ + RoomInviteError, RoomInviteResponse, RoomKickError, RoomKickResponse, RoomPreset, \ + RoomPutStateError, RoomPutStateResponse, RoomResolveAliasResponse, RoomVisibility, TransferMonitor, \ + UploadError, UploadResponse class Matrix: @@ -263,7 +267,7 @@ class Matrix: @classmethod @async_to_sync - async def kick(cls, room_id: str, user_id: str, reason: str = None) -> Union[RoomKickResponse, RoomInviteError]: + async def kick(cls, room_id: str, user_id: str, reason: str = None) -> Union[RoomKickResponse, RoomKickError]: """ Kick a user from a room, or withdraw their invitation. @@ -370,4 +374,3 @@ class FakeMatrixClient: async def func(*_, **_2): return None return func - diff --git a/corres2math/middlewares.py b/corres2math/middlewares.py index 185eda9..fcd29ba 100644 --- a/corres2math/middlewares.py +++ b/corres2math/middlewares.py @@ -1,8 +1,7 @@ -from django.conf import settings -from django.contrib.auth.models import AnonymousUser, User - from threading import local +from django.conf import settings +from django.contrib.auth.models import AnonymousUser, User from django.contrib.sessions.backends.db import SessionStore USER_ATTR_NAME = getattr(settings, 'LOCAL_USER_ATTR_NAME', '_current_user') diff --git a/corres2math/settings.py b/corres2math/settings.py index 1424f6f..73c4a56 100644 --- a/corres2math/settings.py +++ b/corres2math/settings.py @@ -89,8 +89,7 @@ LOGIN_REDIRECT_URL = "index" TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'corres2math/templates')] - , + 'DIRS': [os.path.join(BASE_DIR, 'corres2math/templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -216,6 +215,6 @@ else: } if os.getenv("CORRES2MATH_STAGE", "dev") == "prod": - from .settings_prod import * + from .settings_prod import * # noqa: F401,F403 else: - from .settings_dev import * + from .settings_dev import * # noqa: F401,F403 diff --git a/corres2math/urls.py b/corres2math/urls.py index ae1e0bb..380cd71 100644 --- a/corres2math/urls.py +++ b/corres2math/urls.py @@ -14,8 +14,8 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path, include -from django.views.defaults import bad_request, permission_denied, page_not_found, server_error +from django.urls import include, path +from django.views.defaults import bad_request, page_not_found, permission_denied, server_error from django.views.generic import TemplateView from registration.views import PhotoAuthorizationView diff --git a/tox.ini b/tox.ini index bb02e3c..27fbf8f 100644 --- a/tox.ini +++ b/tox.ini @@ -12,7 +12,7 @@ deps = -r{toxinidir}/requirements.txt coverage commands = - coverage run --omit='*migrations*,apps/scripts*' --source=apps ./manage.py test apps/ + coverage run --omit='apps/scripts*' --source=apps,corres2math ./manage.py test apps/ coverage report -m [testenv:linters] @@ -25,7 +25,7 @@ deps = pep8-naming pyflakes commands = - flake8 apps/ + flake8 apps/ corres2math/ [flake8] exclude =