diff --git a/README.rst b/README.rst index 7a1d3c2..c22e33b 100644 --- a/README.rst +++ b/README.rst @@ -29,8 +29,8 @@ email backend such as `django-ses `_. Requirements ------------------------------- -- Python 2.7 or 3.5+ -- Django >= 1.8 (supported versions) +- Python 3 +- Django >= 2.2 (supported versions) Installation diff --git a/bandit/backends/base.py b/bandit/backends/base.py index fd7564d..a9e298f 100644 --- a/bandit/backends/base.py +++ b/bandit/backends/base.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import logging import re from email.utils import parseaddr @@ -7,7 +5,7 @@ from django.conf import settings from django.template.loader import render_to_string -logger = logging.getLogger("bandit.backends.base") +logger = logging.getLogger(__name__) class HijackBackendMixin(object): @@ -15,14 +13,14 @@ class HijackBackendMixin(object): This backend mixin intercepts outgoing messages, redirecting them to addresses in the BANDIT_EMAIL setting. - Addresses which are not in ADMINS, SERVER_EMAIL, BANDIT_EMAIL or BANDIT_WHITELIST are - intercepted. + Addresses which are not in ADMINS, SERVER_EMAIL, BANDIT_EMAIL, BANDIT_WHITELIST, or + which do not match BANDIT_REGEX_WHITELIST are intercepted. """ def __init__(self, *args, **kwargs): self.log_only = kwargs.pop("log_only", False) self.log_level = kwargs.pop("log_level", logging.DEBUG) - super(HijackBackendMixin, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def send_messages(self, email_messages): admins = getattr(settings, "ADMINS", ()) @@ -80,11 +78,11 @@ def is_approved(email): # keep track of how many messages were only logged so we # can report them as sent to the caller logged_count += 1 - sent_count = super(HijackBackendMixin, self).send_messages(to_send) or 0 + sent_count = super().send_messages(to_send) or 0 return sent_count + logged_count class LogOnlyBackendMixin(HijackBackendMixin): def __init__(self, *args, **kwargs): kwargs["log_only"] = True - super(LogOnlyBackendMixin, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) diff --git a/bandit/backends/seacuke.py b/bandit/backends/seacuke.py index 06f409c..3c2a82d 100644 --- a/bandit/backends/seacuke.py +++ b/bandit/backends/seacuke.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from seacucumber.backend import SESBackend from bandit.backends.base import HijackBackendMixin, LogOnlyBackendMixin diff --git a/bandit/backends/smtp.py b/bandit/backends/smtp.py index c6ab866..be8a302 100644 --- a/bandit/backends/smtp.py +++ b/bandit/backends/smtp.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.core.mail.backends.smtp import EmailBackend as SMTPBackend from bandit.backends.base import HijackBackendMixin, LogOnlyBackendMixin diff --git a/bandit/tests.py b/bandit/tests.py index 130605f..b8d6e88 100644 --- a/bandit/tests.py +++ b/bandit/tests.py @@ -1,7 +1,4 @@ -from __future__ import unicode_literals - import asyncore -import platform import smtpd import threading from email import message_from_string @@ -22,8 +19,7 @@ class FakeSMTPServer(smtpd.SMTPServer, threading.Thread): def __init__(self, *args, **kwargs): threading.Thread.__init__(self) - if platform.python_version_tuple() >= ("3", "5"): - kwargs.setdefault("decode_data", True) + kwargs.setdefault("decode_data", True) smtpd.SMTPServer.__init__(self, *args, **kwargs) self._sink = [] self.active = False @@ -91,12 +87,10 @@ def tearDownClass(cls): cls.server.stop() def setUp(self): - super(BaseBackendTestCase, self).setUp() self.flush_mailbox() def tearDown(self): self.flush_mailbox() - super(BaseBackendTestCase, self).tearDown() def get_connection(self): raise NotImplementedError("Must define in subclass") diff --git a/dev-requirements.txt b/dev-requirements.txt index c846864..759957d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ . # <- install ourselves caktus-sphinx-theme coverage -django>=2.0,<2.1 +django>=2.2,<3.0 flake8 pre-commit sphinx diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 8f8bf2e..0000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Requirements for ReadTheDocs to build the documentation -caktus-sphinx-theme==0.1.0 diff --git a/setup.py b/setup.py index e490643..eb4c054 100644 --- a/setup.py +++ b/setup.py @@ -14,14 +14,18 @@ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", + "Framework :: Django :: 2.2", + "Framework :: Django :: 3.0", + "Framework :: Django :: 3.1", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules", ], diff --git a/tox.ini b/tox.ini index cc39e75..7f7ef0b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,5 @@ [tox] -envlist = {py36}-{1.8,1.10,1.11}, - {py36,py37,py38,py39}-{2.0} +envlist = {py36,py37,py38,py39}-{2.2,3.0,3.1} [gh-actions] python = @@ -10,9 +9,8 @@ python = 3.9: py39 [testenv] -commands = python -Wmodule runtests.py +commands = python runtests.py deps = - 1.8: Django>=1.8,<1.9 - 1.10: Django>=1.10,<1.11 - 1.11: Django>=1.11,<2.0 - 2.0: Django>=2.0,<2.1 + 2.2: Django>=2.2,<3.0 + 3.0: Django>=3.0,<3.1 + 3.1: Django>=3.1,<3.2