Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #100

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: "22.6.0"
rev: "24.10.0"
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: "5.10.1"
rev: "5.13.2"
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: "4.0.1"
rev: "7.1.1"
hooks:
- id: flake8

- repo: https://github.com/asottile/pyupgrade
rev: "v2.37.1"
rev: "v3.19.0"
hooks:
- id: pyupgrade

- repo: https://github.com/PyCQA/doc8
rev: "0.11.2"
rev: "v1.1.2"
hooks:
- id: doc8
2 changes: 0 additions & 2 deletions demo/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Django settings for demo project.
from __future__ import unicode_literals

DEBUG = True

Expand Down
1 change: 1 addition & 0 deletions demo/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
framework.

"""

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings")
Expand Down
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 0 additions & 1 deletion mail_factory/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Django Mail Manager"""

import django
Expand Down
2 changes: 1 addition & 1 deletion mail_factory/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
2 changes: 0 additions & 2 deletions mail_factory/contrib/auth/forms.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion mail_factory/contrib/auth/mails.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from mail_factory import BaseMail


Expand Down
2 changes: 0 additions & 2 deletions mail_factory/contrib/auth/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from django.contrib.auth.views import PasswordResetView as DjangoPasswordResetView
from django.http import HttpResponseRedirect

Expand Down
3 changes: 0 additions & 3 deletions mail_factory/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


class MissingMailContextParamException(Exception):
pass

Expand Down
3 changes: 1 addition & 2 deletions mail_factory/factory.py
Original file line number Diff line number Diff line change
@@ -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 = {}
Expand Down
3 changes: 1 addition & 2 deletions mail_factory/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django import forms


Expand All @@ -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 = []
Expand Down
3 changes: 1 addition & 2 deletions mail_factory/mails.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from os.path import join

import html2text
Expand All @@ -12,7 +11,7 @@
from .messages import EmailMultiRelated


class BaseMail(object):
class BaseMail:
"""Abstract class that helps creating emails.

You need to define:
Expand Down
7 changes: 3 additions & 4 deletions mail_factory/messages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import re
from email.mime.base import MIMEBase
from os.path import basename
Expand Down Expand Up @@ -29,7 +28,7 @@ def __init__(
alternatives=None,
):
self.related_attachments = []
super(EmailMultiRelated, self).__init__(
super().__init__(
subject,
body,
from_email,
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion mail_factory/models.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
2 changes: 0 additions & 2 deletions mail_factory/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from .test_factory import * # noqa
from .test_forms import * # noqa
from .test_mails import * # noqa
Expand Down
3 changes: 0 additions & 3 deletions mail_factory/tests/test_contrib.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions mail_factory/tests/test_factory.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions mail_factory/tests/test_forms.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions mail_factory/tests/test_mails.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions mail_factory/tests/test_messages.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
11 changes: 4 additions & 7 deletions mail_factory/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -30,7 +27,7 @@ class TemplateTest(TestCase):
"""

def setUp(self):
super(TemplateTest, self).setUp()
super().setUp()

credentials = {
"username": "admin",
Expand Down Expand Up @@ -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()
Expand All @@ -143,7 +140,7 @@ class MockForm(object):
self.assertTrue(response.content.startswith(b"<pre>"))

def test_form_valid_send(self):
class MockForm(object):
class MockForm:
cleaned_data = {"title": "title", "content": "content"}

request = self.factory.get(
Expand Down Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion mail_factory/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""URLconf for mail_factory admin interface."""
from django.conf import settings
from django.urls import re_path
Expand Down
15 changes: 7 additions & 8 deletions mail_factory/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]
Expand All @@ -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}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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
Expand Down
Loading