Skip to content

Commit

Permalink
Merge pull request #133 from moggers87/more-py27-cruft-to-be-removed
Browse files Browse the repository at this point in the history
Remove more Python 2.7 cruft
  • Loading branch information
moggers87 committed Jan 2, 2020
2 parents abe5945 + 9851d2a commit ba9b37f
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 35 deletions.
4 changes: 2 additions & 2 deletions salmon/bounce.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def detect(msg):
return BounceAnalyzer(results, score / BOUNCE_MAX)


class BounceAnalyzer(object):
class BounceAnalyzer:
"""
BounceAnalyzer collects up the score and the headers and gives more
meaningful interaction with them. You can keep it simple and just use
Expand Down Expand Up @@ -265,7 +265,7 @@ def error_for_humans(self):
return "No status codes found in bounce message."


class bounce_to(object):
class bounce_to:
"""
Used to route bounce messages to a handler for either soft or hard bounces.
Set the soft/hard parameters to the function that represents the handler.
Expand Down
4 changes: 2 additions & 2 deletions salmon/confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from salmon import queue, view


class ConfirmationStorage(object):
class ConfirmationStorage:
"""
This is the basic confirmation storage. For simple testing purposes
you can just use the default hash db parameter. If you do a deployment
Expand Down Expand Up @@ -82,7 +82,7 @@ def store(self, target, from_address, expected_secret, pending_message_id):
pending_message_id)


class ConfirmationEngine(object):
class ConfirmationEngine:
"""
The confirmation engine is what does the work of sending a confirmation,
and verifying that it was confirmed properly. In order to use it you
Expand Down
10 changes: 4 additions & 6 deletions salmon/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class EncodingError(Exception):
pass


class ContentEncoding(object):
class ContentEncoding:
"""
Wrapper various content encoding headers
Expand Down Expand Up @@ -163,7 +163,7 @@ def keys(self):
return CONTENT_ENCODING_KEYS


class MailBase(object):
class MailBase:
"""
MailBase is used as the basis of salmon.mail and contains the basics of
encoding an email. You actually can do all your email processing with this
Expand Down Expand Up @@ -286,11 +286,9 @@ class MIMEPart(Message):
encode what you ask it.
"""
def __init__(self, type_, **params):
self.mimetype = type_
super().__init__()

# classes from email.* are all old-style in Python, so don't replace
# this with super()
Message.__init__(self)
self.mimetype = type_

self.add_header('Content-Type', type_, **params)

Expand Down
4 changes: 2 additions & 2 deletions salmon/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _decode_header_randomness(addr):
raise encoding.EncodingError("Address must be a string or a list not: %r", type(addr))


class MailRequest(object):
class MailRequest:
"""
This is what is given to your message handlers. The information you get out
of this is *ALWAYS* in Python str and should be usable by any API.
Expand Down Expand Up @@ -159,7 +159,7 @@ def original(self):
return self.Data


class MailResponse(object):
class MailResponse:
"""
You are given MailResponse objects from the salmon.view methods, and
whenever you want to generate an email to send to someone. It has
Expand Down
2 changes: 1 addition & 1 deletion salmon/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, msg, data):
self.data = data


class Queue(object):
class Queue:
"""
Provides a simplified API for dealing with 'queues' in Salmon.
It currently just supports Maildir queues since those are the
Expand Down
12 changes: 6 additions & 6 deletions salmon/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def DEFAULT_STATE_KEY(mod, msg):
return mod


class StateStorage(object):
class StateStorage:
"""
The base storage class you need to implement for a custom storage
system.
Expand Down Expand Up @@ -149,7 +149,7 @@ def get(self, key, sender):
"""
with self.lock:
self.states = shelve.open(self.database_path)
value = super(ShelveStorage, self).get(key.encode('ascii'), sender)
value = super().get(key.encode('ascii'), sender)
self.states.close()
return value

Expand All @@ -159,7 +159,7 @@ def set(self, key, sender, state):
"""
with self.lock:
self.states = shelve.open(self.database_path)
super(ShelveStorage, self).set(key.encode('ascii'), sender, state)
super().set(key.encode('ascii'), sender, state)
self.states.close()

def clear(self):
Expand All @@ -169,11 +169,11 @@ def clear(self):
"""
with self.lock:
self.states = shelve.open(self.database_path)
super(ShelveStorage, self).clear()
super().clear()
self.states.close()


class RoutingBase(object):
class RoutingBase:
"""
The self is a globally accessible class that is actually more like a
glorified module. It is used mostly internally by the salmon.routing
Expand Down Expand Up @@ -439,7 +439,7 @@ def reload(self):
Router = RoutingBase()


class route(object):
class route:
"""
The @route decorator is attached to state handlers to configure them in the
Router so they handle messages for them. The way this works is, rather than
Expand Down
4 changes: 2 additions & 2 deletions salmon/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def error_for_code(self, code):
return " ".join([primary, secondary, combined]).strip()


class Relay(object):
class Relay:
"""
Used to talk to your "relay server" or smart host, this is probably the most
important class in the handlers next to the salmon.routing.Router.
Expand Down Expand Up @@ -287,7 +287,7 @@ def close(self):
logging.error(trace)


class QueueReceiver(object):
class QueueReceiver:
"""
Rather than listen on a socket this will watch a queue directory and
process messages it receives from that. It works in almost the exact
Expand Down
2 changes: 1 addition & 1 deletion salmon/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def delivered(pattern, to_queue=None):
return False


class TestConversation(object):
class TestConversation:
"""
Used to easily do conversations with an email server such that you
send a message and then expect certain responses.
Expand Down
4 changes: 2 additions & 2 deletions tests/bounce_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

class BounceTestCase(SalmonTestCase):
def setUp(self):
super(BounceTestCase, self).setUp()
super().setUp()
Router.load(["tests.handlers.bounce_filtered_mod"])
Router.reload()

def tearDown(self):
super(BounceTestCase, self).tearDown()
super().tearDown()
Router.HANDLERS.clear()
Router.reload()

Expand Down
12 changes: 6 additions & 6 deletions tests/command_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def make_fake_pid_file():
class CliRunner(testing.CliRunner):
def invoke(self, *args, **kwargs):
kwargs.setdefault("catch_exceptions", False)
return super(CliRunner, self).invoke(*args, **kwargs)
return super().invoke(*args, **kwargs)


class CommandTestCase(SalmonTestCase):
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_non_daemon(self, settings_mock, daemon_mock):

class CleanseCommandTestCase(SalmonTestCase):
def setUp(self):
super(CleanseCommandTestCase, self).setUp()
super().setUp()
queue.Queue("run/queue").clear()

def test_cleanse_command(self):
Expand Down Expand Up @@ -211,7 +211,7 @@ def test_encoding_error(self, from_message):

class GenCommandTestCase(SalmonTestCase):
def setUp(self):
super(GenCommandTestCase, self).setUp()
super().setUp()
tmp_dir = mkdtemp()
self.project = os.path.join(tmp_dir, 'testproject')

Expand Down Expand Up @@ -245,7 +245,7 @@ def test_force(self):

class StopCommandTestCase(SalmonTestCase):
def setUp(self):
super(StopCommandTestCase, self).setUp()
super().setUp()
patcher = patch("os.kill")
patcher.start()
self.addCleanup(patcher.stop)
Expand Down Expand Up @@ -290,7 +290,7 @@ def test_stop_force_oserror(self):

class RoutesCommandTestCase(SalmonTestCase):
def setUp(self):
super(RoutesCommandTestCase, self).setUp()
super().setUp()
if "salmon.handlers.log" in sys.modules:
del sys.modules["salmon.handlers.log"]
routing.Router.clear_routes()
Expand Down Expand Up @@ -358,7 +358,7 @@ def test_no_test(self):

class BlastCommandTestCase(SalmonTestCase):
def setUp(self):
super(BlastCommandTestCase, self).setUp()
super().setUp()
queue.Queue("run/queue").clear()

@patch("salmon.server.smtplib.SMTP")
Expand Down
4 changes: 2 additions & 2 deletions tests/confirm_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

class ConfirmationTestCase(SalmonTestCase):
def setUp(self):
super(ConfirmationTestCase, self).setUp()
super().setUp()
self.storage = ConfirmationStorage()
self.engine = ConfirmationEngine('run/confirm', self.storage)
view.LOADER = jinja2.Environment(loader=jinja2.FileSystemLoader('tests/data/templates'))

def tearDown(self):
super(ConfirmationTestCase, self).tearDown()
super().tearDown()
view.LOADER = None

def test_ConfirmationStorage(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def tearDownClass(cls):
rmtree(os.path.join(cls._cwd, path), ignore_errors=True)

def setUp(self):
super(IntegrationTestCase, self).setUp()
super().setUp()
# re-create destoryed queues
queue.Queue(os.path.join(self._cwd, server_settings.UNDELIVERABLE_QUEUE)).clear()
queue.Queue(os.path.join(self._cwd, server_settings.QUEUE_PATH)).clear()
Expand Down
2 changes: 1 addition & 1 deletion tests/routing_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_StateStorage_clear_raises(self):
s.clear()

def test_route___get___raises(self):
class BadRoute(object):
class BadRoute:

@route("test")
def wont_work(message, **kw):
Expand Down
2 changes: 1 addition & 1 deletion tests/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class UtilsTestCase(SalmonTestCase):
def tearDown(self):
super(UtilsTestCase, self).tearDown()
super().tearDown()
self.clear_settings()

def clear_settings(self):
Expand Down

0 comments on commit ba9b37f

Please sign in to comment.