Skip to content

Commit 432a10a

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent aa8c5c4 commit 432a10a

22 files changed

+19
-58
lines changed

demo/settings.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Django settings for demo project.
3-
from __future__ import unicode_literals
42

53
DEBUG = True
64

docs/source/conf.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# django-mail-factory documentation build configuration file, created by
43
# sphinx-quickstart on Wed Jan 23 17:31:52 2013.

mail_factory/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""Django Mail Manager"""
32

43
import django

mail_factory/apps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class MailFactoryConfig(AppConfig):
1111
verbose_name = _("Mail Factory")
1212

1313
def ready(self):
14-
super(MailFactoryConfig, self).ready()
14+
super().ready()
1515
for app in self.apps.get_app_configs():
1616
try:
1717
import_module(name=".mails", package=app.module.__name__)

mail_factory/contrib/auth/forms.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
from django.contrib.auth.forms import PasswordResetForm as DjangoPasswordResetForm
42
from django.contrib.auth.tokens import default_token_generator
53
from django.contrib.sites.shortcuts import get_current_site

mail_factory/contrib/auth/mails.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from mail_factory import BaseMail
32

43

mail_factory/contrib/auth/views.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
from django.contrib.auth.views import PasswordResetView as DjangoPasswordResetView
42
from django.http import HttpResponseRedirect
53

mail_factory/exceptions.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
3-
41
class MissingMailContextParamException(Exception):
52
pass
63

mail_factory/factory.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# -*- coding: utf-8 -*-
21
import base64
32

43
from . import exceptions
54
from .forms import MailForm
65

76

8-
class MailFactory(object):
7+
class MailFactory:
98
mail_form = MailForm
109
_registry = {} # Needed: django.utils.module_loading.autodiscover_modules.
1110
form_map = {}

mail_factory/forms.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django import forms
32

43

@@ -17,7 +16,7 @@ def __init__(self, *args, **kwargs):
1716
if "mail_class" in kwargs:
1817
self.mail_class = kwargs.pop("mail_class")
1918

20-
super(MailForm, self).__init__(*args, **kwargs)
19+
super().__init__(*args, **kwargs)
2120

2221
if self.mail_class is not None:
2322
ordering = []

mail_factory/mails.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from os.path import join
32

43
import html2text
@@ -12,7 +11,7 @@
1211
from .messages import EmailMultiRelated
1312

1413

15-
class BaseMail(object):
14+
class BaseMail:
1615
"""Abstract class that helps creating emails.
1716
1817
You need to define:

mail_factory/messages.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import re
32
from email.mime.base import MIMEBase
43
from os.path import basename
@@ -29,7 +28,7 @@ def __init__(
2928
alternatives=None,
3029
):
3130
self.related_attachments = []
32-
super(EmailMultiRelated, self).__init__(
31+
super().__init__(
3332
subject,
3433
body,
3534
from_email,
@@ -82,7 +81,7 @@ def _create_alternatives(self, msg):
8281
)
8382
self.alternatives[i] = (content, mimetype)
8483

85-
return super(EmailMultiRelated, self)._create_alternatives(msg)
84+
return super()._create_alternatives(msg)
8685

8786
def _create_related_attachments(self, msg):
8887
encoding = self.encoding or settings.DEFAULT_CHARSET
@@ -101,7 +100,7 @@ def _create_related_attachment(self, filename, content, mimetype=None):
101100
object. Adjust headers to use Content-ID where applicable.
102101
Taken from http://code.djangoproject.com/ticket/4771
103102
"""
104-
attachment = super(EmailMultiRelated, self)._create_attachment(
103+
attachment = super()._create_attachment(
105104
filename, content, mimetype
106105
)
107106
if filename:

mail_factory/models.py

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
# -*- coding: utf-8 -*-

mail_factory/tests/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
from .test_factory import * # noqa
42
from .test_forms import * # noqa
53
from .test_mails import * # noqa

mail_factory/tests/test_contrib.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Keep in mind throughout those tests that the mails from demo.demo_app.mails
42
are automatically registered, and serve as fixture."""
53

6-
from __future__ import unicode_literals
74

85
from django.contrib import admin
96
from django.contrib.auth.models import User

mail_factory/tests/test_factory.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Keep in mind throughout those tests that the mails from demo.demo_app.mails
42
are automatically registered, and serve as fixture."""
53

6-
from __future__ import unicode_literals
74

85
from django.conf import settings
96
from django.test import TestCase
@@ -127,7 +124,7 @@ def test_get_raw_content(self):
127124

128125
class FactoryMailTest(TestCase):
129126
def setUp(self):
130-
class MockMail(object): # mock mail to check if its methods are called
127+
class MockMail: # mock mail to check if its methods are called
131128
mail_admins_called = False
132129
send_called = False
133130
template_name = "mockmail"

mail_factory/tests/test_forms.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Keep in mind throughout those tests that the mails from demo.demo_app.mails
42
are automatically registered, and serve as fixture."""
53

6-
from __future__ import unicode_literals
74

85
from django import forms
96
from django.test import TestCase

mail_factory/tests/test_mails.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Keep in mind throughout those tests that the mails from demo.demo_app.mails
42
are automatically registered, and serve as fixture."""
53

6-
from __future__ import unicode_literals
74

85
from django.conf import settings
96
from django.contrib.staticfiles import finders

mail_factory/tests/test_messages.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Keep in mind throughout those tests that the mails from demo.demo_app.mails
42
are automatically registered, and serve as fixture."""
53

6-
from __future__ import unicode_literals
74

85
from os.path import basename
96

mail_factory/tests/test_views.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Keep in mind throughout those tests that the mails from demo.demo_app.mails
42
are automatically registered, and serve as fixture."""
53

6-
from __future__ import unicode_literals
74

85
from django.contrib.auth.models import User
96
from django.http import Http404, HttpResponse
@@ -30,7 +27,7 @@ class TemplateTest(TestCase):
3027
"""
3128

3229
def setUp(self):
33-
super(TemplateTest, self).setUp()
30+
super().setUp()
3431

3532
credentials = {
3633
"username": "admin",
@@ -131,7 +128,7 @@ def test_get_form_class(self):
131128
self.assertEqual(view.get_form_class(), MailForm)
132129

133130
def test_form_valid_raw(self):
134-
class MockForm(object):
131+
class MockForm:
135132
cleaned_data = {"title": "title", "content": "content"}
136133

137134
view = views.MailFormView()
@@ -143,7 +140,7 @@ class MockForm(object):
143140
self.assertTrue(response.content.startswith(b"<pre>"))
144141

145142
def test_form_valid_send(self):
146-
class MockForm(object):
143+
class MockForm:
147144
cleaned_data = {"title": "title", "content": "content"}
148145

149146
request = self.factory.get(
@@ -173,7 +170,7 @@ def mock_factory_mail(mail_name, to, context):
173170
self.assertEqual(response["location"], reverse("mail_factory_list"))
174171

175172
def test_form_valid_html(self):
176-
class MockForm(object):
173+
class MockForm:
177174
cleaned_data = {"title": "title", "content": "content"}
178175

179176
def get_context_data(self):

mail_factory/urls.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""URLconf for mail_factory admin interface."""
32
from django.conf import settings
43
from django.urls import re_path

mail_factory/views.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django.conf import settings
32
from django.contrib import messages
43
from django.contrib.auth.decorators import user_passes_test
@@ -19,7 +18,7 @@ class MailListView(TemplateView):
1918

2019
def get_context_data(self, **kwargs):
2120
"""Return object_list."""
22-
data = super(MailListView, self).get_context_data(**kwargs)
21+
data = super().get_context_data(**kwargs)
2322
mail_list = []
2423
for mail_name, mail_class in sorted(
2524
factory._registry.items(), key=lambda x: x[0]
@@ -29,7 +28,7 @@ def get_context_data(self, **kwargs):
2928
return data
3029

3130

32-
class MailPreviewMixin(object):
31+
class MailPreviewMixin:
3332
def get_html_alternative(self, message):
3433
"""Return the html alternative, if present."""
3534
alternatives = {v: k for k, v in message.alternatives}
@@ -77,10 +76,10 @@ def dispatch(self, request, mail_name):
7776
self.send = "send" in request.POST
7877
self.email = request.POST.get("email")
7978

80-
return super(MailFormView, self).dispatch(request)
79+
return super().dispatch(request)
8180

8281
def get_form_kwargs(self):
83-
kwargs = super(MailFormView, self).get_form_kwargs()
82+
kwargs = super().get_form_kwargs()
8483
kwargs["mail_class"] = self.mail_class
8584
return kwargs
8685

@@ -117,7 +116,7 @@ def form_valid(self, form):
117116
return HttpResponse(html)
118117

119118
def get_context_data(self, **kwargs):
120-
data = super(MailFormView, self).get_context_data(**kwargs)
119+
data = super().get_context_data(**kwargs)
121120
data["mail_name"] = self.mail_name
122121

123122
preview_messages = {}
@@ -147,10 +146,10 @@ def dispatch(self, request, mail_name, lang):
147146
except exceptions.MailFactoryError:
148147
raise Http404
149148

150-
return super(MailPreviewMessageView, self).dispatch(request)
149+
return super().dispatch(request)
151150

152151
def get_context_data(self, **kwargs):
153-
data = super(MailPreviewMessageView, self).get_context_data(**kwargs)
152+
data = super().get_context_data(**kwargs)
154153
message = self.get_mail_preview(self.mail_name, self.lang)
155154
data["mail_name"] = self.mail_name
156155
data["message"] = message

0 commit comments

Comments
 (0)