From f0cbd5974d0abc29fa4e6c62ac3184fd04dad471 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Dec 2022 23:13:59 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- demo/settings.py | 2 -- docs/source/conf.py | 1 - mail_factory/__init__.py | 1 - mail_factory/apps.py | 2 +- mail_factory/contrib/auth/forms.py | 2 -- mail_factory/contrib/auth/mails.py | 1 - mail_factory/contrib/auth/views.py | 2 -- mail_factory/exceptions.py | 3 --- mail_factory/factory.py | 3 +-- mail_factory/forms.py | 3 +-- mail_factory/mails.py | 3 +-- mail_factory/messages.py | 7 +++---- mail_factory/models.py | 1 - mail_factory/tests/__init__.py | 2 -- mail_factory/tests/test_contrib.py | 3 --- mail_factory/tests/test_factory.py | 5 +---- mail_factory/tests/test_forms.py | 3 --- mail_factory/tests/test_mails.py | 3 --- mail_factory/tests/test_messages.py | 3 --- mail_factory/tests/test_views.py | 11 ++++------- mail_factory/urls.py | 1 - mail_factory/views.py | 15 +++++++-------- 22 files changed, 19 insertions(+), 58 deletions(-) diff --git a/demo/settings.py b/demo/settings.py index c0fab18..2c22cf8 100644 --- a/demo/settings.py +++ b/demo/settings.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Django settings for demo project. -from __future__ import unicode_literals DEBUG = True diff --git a/docs/source/conf.py b/docs/source/conf.py index 25026c9..f414f6e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # django-mail-factory documentation build configuration file, created by # sphinx-quickstart on Wed Jan 23 17:31:52 2013. diff --git a/mail_factory/__init__.py b/mail_factory/__init__.py index 5ccf5d7..df68cba 100644 --- a/mail_factory/__init__.py +++ b/mail_factory/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Django Mail Manager""" import django diff --git a/mail_factory/apps.py b/mail_factory/apps.py index 34e047a..0094886 100644 --- a/mail_factory/apps.py +++ b/mail_factory/apps.py @@ -11,7 +11,7 @@ class MailFactoryConfig(AppConfig): verbose_name = _("Mail Factory") def ready(self): - super(MailFactoryConfig, self).ready() + super().ready() for app in self.apps.get_app_configs(): try: import_module(name=".mails", package=app.module.__name__) diff --git a/mail_factory/contrib/auth/forms.py b/mail_factory/contrib/auth/forms.py index fb02315..e6bd690 100644 --- a/mail_factory/contrib/auth/forms.py +++ b/mail_factory/contrib/auth/forms.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from django.contrib.auth.forms import PasswordResetForm as DjangoPasswordResetForm from django.contrib.auth.tokens import default_token_generator from django.contrib.sites.shortcuts import get_current_site diff --git a/mail_factory/contrib/auth/mails.py b/mail_factory/contrib/auth/mails.py index 17633c8..4ed7cae 100644 --- a/mail_factory/contrib/auth/mails.py +++ b/mail_factory/contrib/auth/mails.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from mail_factory import BaseMail diff --git a/mail_factory/contrib/auth/views.py b/mail_factory/contrib/auth/views.py index 9c3074a..d595792 100644 --- a/mail_factory/contrib/auth/views.py +++ b/mail_factory/contrib/auth/views.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from django.contrib.auth.views import PasswordResetView as DjangoPasswordResetView from django.http import HttpResponseRedirect diff --git a/mail_factory/exceptions.py b/mail_factory/exceptions.py index 1326f61..8a98657 100644 --- a/mail_factory/exceptions.py +++ b/mail_factory/exceptions.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- - - class MissingMailContextParamException(Exception): pass diff --git a/mail_factory/factory.py b/mail_factory/factory.py index 2ece5ed..02ba515 100644 --- a/mail_factory/factory.py +++ b/mail_factory/factory.py @@ -1,11 +1,10 @@ -# -*- coding: utf-8 -*- import base64 from . import exceptions from .forms import MailForm -class MailFactory(object): +class MailFactory: mail_form = MailForm _registry = {} # Needed: django.utils.module_loading.autodiscover_modules. form_map = {} diff --git a/mail_factory/forms.py b/mail_factory/forms.py index b1e1477..4855516 100644 --- a/mail_factory/forms.py +++ b/mail_factory/forms.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django import forms @@ -17,7 +16,7 @@ def __init__(self, *args, **kwargs): if "mail_class" in kwargs: self.mail_class = kwargs.pop("mail_class") - super(MailForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) if self.mail_class is not None: ordering = [] diff --git a/mail_factory/mails.py b/mail_factory/mails.py index 704717f..ee39877 100644 --- a/mail_factory/mails.py +++ b/mail_factory/mails.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from os.path import join import html2text @@ -12,7 +11,7 @@ from .messages import EmailMultiRelated -class BaseMail(object): +class BaseMail: """Abstract class that helps creating emails. You need to define: diff --git a/mail_factory/messages.py b/mail_factory/messages.py index 017c5a6..3fcc019 100644 --- a/mail_factory/messages.py +++ b/mail_factory/messages.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import re from email.mime.base import MIMEBase from os.path import basename @@ -29,7 +28,7 @@ def __init__( alternatives=None, ): self.related_attachments = [] - super(EmailMultiRelated, self).__init__( + super().__init__( subject, body, from_email, @@ -82,7 +81,7 @@ def _create_alternatives(self, msg): ) self.alternatives[i] = (content, mimetype) - return super(EmailMultiRelated, self)._create_alternatives(msg) + return super()._create_alternatives(msg) def _create_related_attachments(self, msg): encoding = self.encoding or settings.DEFAULT_CHARSET @@ -101,7 +100,7 @@ def _create_related_attachment(self, filename, content, mimetype=None): object. Adjust headers to use Content-ID where applicable. Taken from http://code.djangoproject.com/ticket/4771 """ - attachment = super(EmailMultiRelated, self)._create_attachment( + attachment = super()._create_attachment( filename, content, mimetype ) if filename: diff --git a/mail_factory/models.py b/mail_factory/models.py index 40a96af..e69de29 100644 --- a/mail_factory/models.py +++ b/mail_factory/models.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/mail_factory/tests/__init__.py b/mail_factory/tests/__init__.py index 4a4cf21..0e862e3 100644 --- a/mail_factory/tests/__init__.py +++ b/mail_factory/tests/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from .test_factory import * # noqa from .test_forms import * # noqa from .test_mails import * # noqa diff --git a/mail_factory/tests/test_contrib.py b/mail_factory/tests/test_contrib.py index 71ccbd0..cc41298 100644 --- a/mail_factory/tests/test_contrib.py +++ b/mail_factory/tests/test_contrib.py @@ -1,9 +1,6 @@ -# -*- coding: utf-8 -*- - """Keep in mind throughout those tests that the mails from demo.demo_app.mails are automatically registered, and serve as fixture.""" -from __future__ import unicode_literals from django.contrib import admin from django.contrib.auth.models import User diff --git a/mail_factory/tests/test_factory.py b/mail_factory/tests/test_factory.py index 4ea65c2..31cba82 100644 --- a/mail_factory/tests/test_factory.py +++ b/mail_factory/tests/test_factory.py @@ -1,9 +1,6 @@ -# -*- coding: utf-8 -*- - """Keep in mind throughout those tests that the mails from demo.demo_app.mails are automatically registered, and serve as fixture.""" -from __future__ import unicode_literals from django.conf import settings from django.test import TestCase @@ -127,7 +124,7 @@ def test_get_raw_content(self): class FactoryMailTest(TestCase): def setUp(self): - class MockMail(object): # mock mail to check if its methods are called + class MockMail: # mock mail to check if its methods are called mail_admins_called = False send_called = False template_name = "mockmail" diff --git a/mail_factory/tests/test_forms.py b/mail_factory/tests/test_forms.py index 644596b..b6e5c02 100644 --- a/mail_factory/tests/test_forms.py +++ b/mail_factory/tests/test_forms.py @@ -1,9 +1,6 @@ -# -*- coding: utf-8 -*- - """Keep in mind throughout those tests that the mails from demo.demo_app.mails are automatically registered, and serve as fixture.""" -from __future__ import unicode_literals from django import forms from django.test import TestCase diff --git a/mail_factory/tests/test_mails.py b/mail_factory/tests/test_mails.py index 6a218a3..b48bb68 100644 --- a/mail_factory/tests/test_mails.py +++ b/mail_factory/tests/test_mails.py @@ -1,9 +1,6 @@ -# -*- coding: utf-8 -*- - """Keep in mind throughout those tests that the mails from demo.demo_app.mails are automatically registered, and serve as fixture.""" -from __future__ import unicode_literals from django.conf import settings from django.contrib.staticfiles import finders diff --git a/mail_factory/tests/test_messages.py b/mail_factory/tests/test_messages.py index 28d4def..970fd34 100644 --- a/mail_factory/tests/test_messages.py +++ b/mail_factory/tests/test_messages.py @@ -1,9 +1,6 @@ -# -*- coding: utf-8 -*- - """Keep in mind throughout those tests that the mails from demo.demo_app.mails are automatically registered, and serve as fixture.""" -from __future__ import unicode_literals from os.path import basename diff --git a/mail_factory/tests/test_views.py b/mail_factory/tests/test_views.py index 096b3bb..3e42764 100644 --- a/mail_factory/tests/test_views.py +++ b/mail_factory/tests/test_views.py @@ -1,9 +1,6 @@ -# -*- coding: utf-8 -*- - """Keep in mind throughout those tests that the mails from demo.demo_app.mails are automatically registered, and serve as fixture.""" -from __future__ import unicode_literals from django.contrib.auth.models import User from django.http import Http404, HttpResponse @@ -30,7 +27,7 @@ class TemplateTest(TestCase): """ def setUp(self): - super(TemplateTest, self).setUp() + super().setUp() credentials = { "username": "admin", @@ -131,7 +128,7 @@ def test_get_form_class(self): self.assertEqual(view.get_form_class(), MailForm) def test_form_valid_raw(self): - class MockForm(object): + class MockForm: cleaned_data = {"title": "title", "content": "content"} view = views.MailFormView() @@ -143,7 +140,7 @@ class MockForm(object): self.assertTrue(response.content.startswith(b"
")) def test_form_valid_send(self): - class MockForm(object): + class MockForm: cleaned_data = {"title": "title", "content": "content"} request = self.factory.get( @@ -173,7 +170,7 @@ def mock_factory_mail(mail_name, to, context): self.assertEqual(response["location"], reverse("mail_factory_list")) def test_form_valid_html(self): - class MockForm(object): + class MockForm: cleaned_data = {"title": "title", "content": "content"} def get_context_data(self): diff --git a/mail_factory/urls.py b/mail_factory/urls.py index f159517..af54b23 100644 --- a/mail_factory/urls.py +++ b/mail_factory/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """URLconf for mail_factory admin interface.""" from django.conf import settings from django.urls import re_path diff --git a/mail_factory/views.py b/mail_factory/views.py index a9cf4b6..8a66cc7 100644 --- a/mail_factory/views.py +++ b/mail_factory/views.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import user_passes_test @@ -19,7 +18,7 @@ class MailListView(TemplateView): def get_context_data(self, **kwargs): """Return object_list.""" - data = super(MailListView, self).get_context_data(**kwargs) + data = super().get_context_data(**kwargs) mail_list = [] for mail_name, mail_class in sorted( factory._registry.items(), key=lambda x: x[0] @@ -29,7 +28,7 @@ def get_context_data(self, **kwargs): return data -class MailPreviewMixin(object): +class MailPreviewMixin: def get_html_alternative(self, message): """Return the html alternative, if present.""" alternatives = {v: k for k, v in message.alternatives} @@ -77,10 +76,10 @@ def dispatch(self, request, mail_name): self.send = "send" in request.POST self.email = request.POST.get("email") - return super(MailFormView, self).dispatch(request) + return super().dispatch(request) def get_form_kwargs(self): - kwargs = super(MailFormView, self).get_form_kwargs() + kwargs = super().get_form_kwargs() kwargs["mail_class"] = self.mail_class return kwargs @@ -117,7 +116,7 @@ def form_valid(self, form): return HttpResponse(html) def get_context_data(self, **kwargs): - data = super(MailFormView, self).get_context_data(**kwargs) + data = super().get_context_data(**kwargs) data["mail_name"] = self.mail_name preview_messages = {} @@ -147,10 +146,10 @@ def dispatch(self, request, mail_name, lang): except exceptions.MailFactoryError: raise Http404 - return super(MailPreviewMessageView, self).dispatch(request) + return super().dispatch(request) def get_context_data(self, **kwargs): - data = super(MailPreviewMessageView, self).get_context_data(**kwargs) + data = super().get_context_data(**kwargs) message = self.get_mail_preview(self.mail_name, self.lang) data["mail_name"] = self.mail_name data["message"] = message