Skip to content

Commit 438eb9b

Browse files
committed
Fix flake8 errors
1 parent 2eeb07a commit 438eb9b

File tree

7 files changed

+35
-13
lines changed

7 files changed

+35
-13
lines changed

mailauth/contrib/admin/views.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def get_context_data(self, **kwargs):
1818
'username': self.request.user.get_username(),
1919
})
2020
if (REDIRECT_FIELD_NAME not in self.request.GET and
21-
REDIRECT_FIELD_NAME not in self.request.POST):
22-
context[REDIRECT_FIELD_NAME] = reverse('admin:index', current_app=self.site.name)
21+
REDIRECT_FIELD_NAME not in self.request.POST):
22+
context[REDIRECT_FIELD_NAME] = reverse(
23+
'admin:index', current_app=self.site.name
24+
)
2325
return context

mailauth/forms.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ def __init__(self, request, *args, **kwargs):
105105
self.fields[self.field_name] = field
106106

107107
def get_users(self, email=None):
108-
return get_user_model()._default_manager.filter(**{self.field_name: email}).iterator()
108+
return get_user_model()._default_manager.filter(
109+
**{self.field_name: email}
110+
).iterator()
109111

110112
def save(self):
111113
"""
@@ -125,7 +127,9 @@ def send_mail(self, to_email, context):
125127
subject = ''.join(subject.splitlines())
126128
body = loader.render_to_string(self.email_template_name, context)
127129

128-
email_message = EmailMultiAlternatives(subject, body, self.from_email, [to_email])
130+
email_message = EmailMultiAlternatives(
131+
subject, body, self.from_email, [to_email]
132+
)
129133
try:
130134
template = loader.get_template(self.html_email_template_name)
131135
except TemplateDoesNotExist:

mailauth/signing.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def sign(self, user):
3838
when it has been issued.
3939
4040
Args:
41-
user (django.contrib.auth.base_user.AbstractBaseUser): User object to issue a token for.
41+
user (django.contrib.auth.base_user.AbstractBaseUser):
42+
User object to issue a token for.
4243
4344
Returns:
4445
str: URL safe base64 string.
@@ -84,5 +85,7 @@ def unsign(self, value, max_age=None):
8485
raise UserDoesNotExist("User with pk=%s does not exist" % user_pk) from e
8586
else:
8687
if last_login != '' and self.to_timestamp(user.last_login) != last_login:
87-
raise signing.SignatureExpired("The access token for %r seems used" % user)
88+
raise signing.SignatureExpired(
89+
"The access token for %r seems used" % user
90+
)
8891
return user

mailauth/views.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class LoginView(DjangoLoginView):
1818
"""
1919
Send a login code to the user.
2020
21-
It doesn't authenticate a user but it is the entry point for the login process (login URL).
21+
It doesn't authenticate a user but it is the entry point for the login
22+
process (login URL).
2223
"""
2324

2425
form_class = forms.EmailLoginForm

setup.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ commands = python setup.py build_sphinx -W -b doctest -b html
7575
source-dir = docs
7676
build-dir = docs/_build
7777

78-
[falke8]
78+
[flake8]
7979
max-line-length=88
80-
exclude = venv,.tox,.eggs
80+
exclude = venv,.tox,.eggs,migrations
8181

8282
[pydocstyle]
8383
add_ignore = D1

tests/contrib/admin/test_views.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ def test_get(self, client):
1010
assert b'id="id_email"' in response.content
1111

1212
def test_post(self, client, user, signature):
13-
response = client.post('/admin/login/', data={'email': 'spiderman@avengers.com'})
13+
response = client.post(
14+
'/admin/login/',
15+
data={'email': 'spiderman@avengers.com'}
16+
)
1417
assert response.status_code == 302, response.content.decode()
1518
assert signature in mail.outbox[-1].body
1619

1720
def test_post__user_does_not_exist(self, db, client):
18-
response = client.post('/admin/login/', data={'email': 'superman@avengers.com'})
21+
response = client.post(
22+
'/admin/login/',
23+
data={'email': 'superman@avengers.com'}
24+
)
1925
assert response.status_code == 302, response.content.decode()
2026
assert not mail.outbox

tests/test_signing.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ def test_unsign(self, db, signer, signature):
2020
assert user == signer.unsign(signature)
2121

2222
def test_unsign__no_user(self, db, signer, signature):
23-
with pytest.raises(signing.UserDoesNotExist, match="User with pk=1337 does not exist"):
23+
with pytest.raises(
24+
signing.UserDoesNotExist,
25+
match="User with pk=1337 does not exist"
26+
):
2427
signer.unsign(signature)
2528

2629
def test_unsign__last_login(self, db, signer, signature):
@@ -30,7 +33,10 @@ def test_unsign__last_login(self, db, signer, signature):
3033
# later date, that does not match the signature
3134
last_login=timezone.datetime(2012, 7, 3, tzinfo=timezone.utc),
3235
)
33-
with pytest.raises(SignatureExpired, match="The access token for <EmailUser: spiderman@avengers.com> seems used"):
36+
with pytest.raises(
37+
SignatureExpired,
38+
match="The access token for <EmailUser: spiderman@avengers.com> seems used"
39+
):
3440
signer.unsign(signature)
3541

3642
def test_to_timestamp(self):

0 commit comments

Comments
 (0)