From 402b5443937a35a94deb4b138c257d42973a2a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delobelle?= Date: Sat, 6 Oct 2018 12:47:19 +0200 Subject: [PATCH] core -- Fix flake8 errors --- bda/algorithm.py | 2 -- bda/management/commands/manage_reventes.py | 4 +++- bda/management/commands/sendrappels.py | 5 ++++- bda/models.py | 2 +- bda/tests/test_revente.py | 2 +- gestioncof/apps.py | 2 +- gestioncof/decorators.py | 4 ++-- gestioncof/shared.py | 2 -- kfet/admin.py | 3 --- kfet/cms/apps.py | 2 +- kfet/forms.py | 2 +- kfet/models.py | 3 +-- kfet/views.py | 6 +----- 13 files changed, 16 insertions(+), 23 deletions(-) delete mode 100644 kfet/admin.py diff --git a/bda/algorithm.py b/bda/algorithm.py index 830ef119..add09335 100644 --- a/bda/algorithm.py +++ b/bda/algorithm.py @@ -1,7 +1,5 @@ import random -from django.db.models import Max - class Algorithm(object): diff --git a/bda/management/commands/manage_reventes.py b/bda/management/commands/manage_reventes.py index 52d25252..bd25a28e 100644 --- a/bda/management/commands/manage_reventes.py +++ b/bda/management/commands/manage_reventes.py @@ -9,7 +9,9 @@ from bda.models import SpectacleRevente class Command(BaseCommand): - help = "Envoie les mails de notification et effectue " "les tirages au sort des reventes" + help = ( + "Envoie les mails de notification et effectue les tirages au sort des reventes" + ) leave_locale_alone = True def handle(self, *args, **options): diff --git a/bda/management/commands/sendrappels.py b/bda/management/commands/sendrappels.py index 33f85330..65026736 100644 --- a/bda/management/commands/sendrappels.py +++ b/bda/management/commands/sendrappels.py @@ -11,7 +11,10 @@ from bda.models import Spectacle class Command(BaseCommand): - help = "Envoie les mails de rappel des spectacles dont la date " "approche.\nNe renvoie pas les mails déjà envoyés." + help = ( + "Envoie les mails de rappel des spectacles dont la date approche.\n" + "Ne renvoie pas les mails déjà envoyés." + ) leave_locale_alone = True def handle(self, *args, **options): diff --git a/bda/models.py b/bda/models.py index bd4ea4cb..9ac38a41 100644 --- a/bda/models.py +++ b/bda/models.py @@ -98,7 +98,7 @@ class Spectacle(models.Model): """ try: return self.image.url - except: + except Exception: return None def send_rappel(self): diff --git a/bda/tests/test_revente.py b/bda/tests/test_revente.py index b0d69dc7..202e9494 100644 --- a/bda/tests/test_revente.py +++ b/bda/tests/test_revente.py @@ -1,7 +1,7 @@ from datetime import timedelta from django.contrib.auth.models import User -from django.test import Client, TestCase +from django.test import TestCase from django.utils import timezone from bda.models import ( diff --git a/gestioncof/apps.py b/gestioncof/apps.py index b132366a..88e2fbfc 100644 --- a/gestioncof/apps.py +++ b/gestioncof/apps.py @@ -6,7 +6,7 @@ class GestioncofConfig(AppConfig): verbose_name = "Gestion des adhérents du COF" def ready(self): - from . import signals + from . import signals # noqa self.register_config() diff --git a/gestioncof/decorators.py b/gestioncof/decorators.py index fe5a7ccc..ef811730 100644 --- a/gestioncof/decorators.py +++ b/gestioncof/decorators.py @@ -5,7 +5,7 @@ def is_cof(user): try: profile = user.profile return profile.is_cof - except: + except Exception: return False @@ -16,7 +16,7 @@ def is_buro(user): try: profile = user.profile return profile.is_buro - except: + except Exception: return False diff --git a/gestioncof/shared.py b/gestioncof/shared.py index 87e19842..1a5bd32e 100644 --- a/gestioncof/shared.py +++ b/gestioncof/shared.py @@ -2,8 +2,6 @@ from django.conf import settings from django.contrib.sites.models import Site from django_cas_ng.backends import CASBackend -from gestioncof.models import CofProfile - class COFCASBackend(CASBackend): def clean_username(self, username): diff --git a/kfet/admin.py b/kfet/admin.py deleted file mode 100644 index 8c38f3f3..00000000 --- a/kfet/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/kfet/cms/apps.py b/kfet/cms/apps.py index d4928ac6..d675cbb5 100644 --- a/kfet/cms/apps.py +++ b/kfet/cms/apps.py @@ -7,4 +7,4 @@ class KFetCMSAppConfig(AppConfig): verbose_name = "CMS K-Fêt" def ready(self): - from . import hooks + from . import hooks # noqa diff --git a/kfet/forms.py b/kfet/forms.py index b253fd67..e314d80c 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -219,7 +219,7 @@ class CheckoutStatementCreateForm(forms.ModelForm): or self.cleaned_data["balance_500"] is None ): raise ValidationError( - "Y'a un problème. Si tu comptes la caisse, mets au moins des 0 stp (et t'as pas idée de comment c'est long de vérifier que t'as mis des valeurs de partout...)" + "Y'a un problème. Si tu comptes la caisse, mets au moins des 0 stp." ) super().clean() diff --git a/kfet/models.py b/kfet/models.py index 6b16505e..5a8ea858 100644 --- a/kfet/models.py +++ b/kfet/models.py @@ -8,7 +8,6 @@ from django.db import models, transaction from django.db.models import F from django.urls import reverse from django.utils import timezone -from django.utils.six.moves import reduce from django.utils.translation import ugettext_lazy as _ from gestioncof.models import CofProfile @@ -164,7 +163,7 @@ class Account(models.Model): pattern = re.compile("^[^a-z]{3}$") data["is_valid"] = pattern.match(trigramme) and True or False try: - account = Account.objects.get(trigramme=trigramme) + Account.objects.get(trigramme=trigramme) except Account.DoesNotExist: data["is_free"] = True return data diff --git a/kfet/views.py b/kfet/views.py index 088f867e..a2a69930 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -2,7 +2,6 @@ import ast import heapq import statistics from collections import defaultdict -from datetime import timedelta from decimal import Decimal from urllib.parse import urlencode @@ -10,12 +9,10 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.models import Permission, User from django.contrib.messages.views import SuccessMessageMixin -from django.core.cache import cache from django.core.exceptions import PermissionDenied from django.core.urlresolvers import reverse, reverse_lazy from django.db import transaction from django.db.models import Count, F, Prefetch, Sum -from django.db.models.functions import Coalesce from django.forms import formset_factory from django.http import Http404, JsonResponse from django.shortcuts import get_object_or_404, redirect, render @@ -30,7 +27,6 @@ from kfet import consumers from kfet.config import kfet_config from kfet.decorators import teamkfet_required from kfet.forms import ( - AccountBalanceForm, AccountForm, AccountNegativeForm, AccountNoTriForm, @@ -80,7 +76,7 @@ from kfet.models import ( Transfer, TransferGroup, ) -from kfet.statistic import ScaleMixin, WeekScale, last_stats_manifest, tot_ventes +from kfet.statistic import ScaleMixin, WeekScale, last_stats_manifest from .auth.views import ( # noqa AccountGroupCreate,