From 0d60075f280e0cd5d54f3cb143631a14dddd8d18 Mon Sep 17 00:00:00 2001 From: winkidney Date: Fri, 22 Feb 2019 17:40:02 +0800 Subject: [PATCH] flake8 --- core/context_processors.py | 1 - core/tests/views.py | 2 -- core/utils.py | 1 + django_images/tests.py | 6 +++--- pinry/wsgi.py | 4 +--- users/__init__.py | 1 - users/auth/backends.py | 8 +++++--- users/forms.py | 12 ++++++++---- users/middleware.py | 3 ++- users/views.py | 3 ++- 10 files changed, 22 insertions(+), 19 deletions(-) diff --git a/core/context_processors.py b/core/context_processors.py index 34da9f9..dd633b0 100644 --- a/core/context_processors.py +++ b/core/context_processors.py @@ -5,4 +5,3 @@ def template_settings(request): return { 'API_LIMIT_PER_PAGE': settings.API_LIMIT_PER_PAGE, } - diff --git a/core/tests/views.py b/core/tests/views.py index 7cb10b4..1a86135 100644 --- a/core/tests/views.py +++ b/core/tests/views.py @@ -1,6 +1,4 @@ -from django.conf import settings from django.core.urlresolvers import reverse -from django.template import TemplateDoesNotExist from django.test import TestCase from core.models import Image diff --git a/core/utils.py b/core/utils.py index 044ce8f..1a486db 100644 --- a/core/utils.py +++ b/core/utils.py @@ -1,6 +1,7 @@ import hashlib import os + def upload_path(instance, filename, **kwargs): hasher = hashlib.md5() for chunk in instance.image.chunks(): diff --git a/django_images/tests.py b/django_images/tests.py index 736e54a..90d824e 100644 --- a/django_images/tests.py +++ b/django_images/tests.py @@ -20,7 +20,7 @@ class ImageModelTest(TestCase): def test_get_by_size(self): size = list(settings.IMAGE_SIZES.keys())[0] - thumb = Thumbnail.objects.get_or_create_at_size(self.image.id, size) + Thumbnail.objects.get_or_create_at_size(self.image.id, size) self.image.get_by_size(size) def test_get_absolute_url(self): @@ -53,7 +53,7 @@ class ThumbnailManagerModelTest(TestCase): # TODO: Test the image object and data def test_create(self): - thumb = Thumbnail.objects.get_or_create_at_size(self.image.id, self.size) + Thumbnail.objects.get_or_create_at_size(self.image.id, self.size) self.assertEqual(self.image.thumbnail_set.count(), 1) def test_get(self): @@ -89,7 +89,7 @@ class PostSaveSignalOriginalChangedTestCase(TestCase): def test_post_save_signal_original_changed(self): size = list(settings.IMAGE_SIZES.keys())[0] - thumb = Thumbnail.objects.get_or_create_at_size(self.image.id, size) + Thumbnail.objects.get_or_create_at_size(self.image.id, size) self.image.delete() self.assertFalse(Thumbnail.objects.exists()) diff --git a/pinry/wsgi.py b/pinry/wsgi.py index 5d609f5..fdf910d 100644 --- a/pinry/wsgi.py +++ b/pinry/wsgi.py @@ -1,8 +1,6 @@ import os +from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinry.settings.docker") - - -from django.core.wsgi import get_wsgi_application application = get_wsgi_application() diff --git a/users/__init__.py b/users/__init__.py index 8b13789..e69de29 100644 --- a/users/__init__.py +++ b/users/__init__.py @@ -1 +0,0 @@ - diff --git a/users/auth/backends.py b/users/auth/backends.py index e871f9e..5048844 100644 --- a/users/auth/backends.py +++ b/users/auth/backends.py @@ -1,15 +1,17 @@ import re -from core.models import Pin from users.models import User + email_re = re.compile( - r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom + r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom # quoted-string, see also http://tools.ietf.org/html/rfc2822#section-3.2.5 r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"' r')@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)$)' # domain - r'|\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$', re.IGNORECASE) # literal form, ipv4 address (SMTP 4.1.3) + r'|\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$', + re.IGNORECASE +) # literal form, ipv4 address (SMTP 4.1.3) class CombinedAuthBackend(object): diff --git a/users/forms.py b/users/forms.py index ed15a3d..e072383 100644 --- a/users/forms.py +++ b/users/forms.py @@ -11,10 +11,14 @@ class UserCreationForm(forms.ModelForm): error_messages = { 'duplicate_username': _("A user with that username already exists."), } - username = forms.RegexField(label=_("Username"), max_length=30, - regex=r'^[\w-]+$') - password = forms.CharField(label=_("Password"), - widget=forms.PasswordInput) + username = forms.RegexField( + label=_("Username"), max_length=30, + regex=r'^[\w-]+$' + ) + password = forms.CharField( + label=_("Password"), + widget=forms.PasswordInput + ) class Meta: model = User diff --git a/users/middleware.py b/users/middleware.py index 71234d1..e2dbdcf 100644 --- a/users/middleware.py +++ b/users/middleware.py @@ -4,8 +4,9 @@ from django.core.urlresolvers import reverse class Public(object): + def process_request(self, request): - if settings.PUBLIC == False and not request.user.is_authenticated(): + if settings.PUBLIC is False and not request.user.is_authenticated(): acceptable_paths = [ '/login/', '/private/', diff --git a/users/views.py b/users/views.py index 703aead..bbfb9a2 100644 --- a/users/views.py +++ b/users/views.py @@ -13,7 +13,8 @@ from .forms import UserCreationForm from users.models import User -reverse_lazy = lambda name=None, *args: lazy(reverse, str)(name, args=args) +def reverse_lazy(name=None, *args): + return lazy(reverse, str)(name, args=args) class CreateUser(CreateView):