Skip to content

Commit

Permalink
Improve documentation and flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
pfouque committed May 24, 2024
1 parent 88e17ea commit 6dcded0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
17 changes: 7 additions & 10 deletions django_mailbox/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def _get_dehydrated_message(self, msg, record):
new = EmailMessage()
if (
msg.is_multipart()
and not 'attachment' in msg.get('Content-Disposition', '')
and 'attachment' not in msg.get('Content-Disposition', '')
):
for header, value in msg.items():
new[header] = value
Expand Down Expand Up @@ -647,20 +647,18 @@ def to_addresses(self):
return addresses

def reply(self, message):
"""Sends a message as a reply to this message instance.
Although Django's e-mail processing will set both Message-ID
and Date upon generating the e-mail message, we will not be able
to retrieve that information through normal channels, so we must
pre-set it.
For conveninence, you can use django.core.mail.EmailMessage to build a Message instance::
"""Sends an EmailMessage as a reply to this message instance::
from django.core.mail import EmailMessage
message.reply(
EmailMessage(subject="pong", body="pongpong")
)
Although Django's e-mail processing will set both Message-ID
and Date upon generating the e-mail message, we will not be able
to retrieve that information through normal channels, so we must
pre-set it.
"""
from django.core.mail import EmailMessage as DjangoEmailMessage

Expand Down Expand Up @@ -900,7 +898,6 @@ def __str__(self):
return f'{self.get_filename()}: {self.document.url}'
return self.get_filename()


class Meta:
verbose_name = _('Message attachment')
verbose_name_plural = _('Message attachments')
5 changes: 4 additions & 1 deletion django_mailbox/tests/test_process_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ def test_message_reply(self):
)
msg = self.mailbox.record_outgoing_message(email_object.message())

with self.assertRaises(ValueError):
msg.reply(Message(subject="ping", body="pong"))

self.assertTrue(msg.outgoing)

actual_from = '[email protected]'
Expand Down Expand Up @@ -439,7 +442,7 @@ def test_message_compressed(self):

msg = self.mailbox.process_incoming_message(message)

actual_email_object = msg.get_email_object()
_actual_email_object = msg.get_email_object()

self.assertTrue(msg.eml.name.endswith('.eml.gz'))

Expand Down
2 changes: 1 addition & 1 deletion django_mailbox/transports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ def get_email_from_bytes(self, contents):
return message

def close(self):
pass
pass
2 changes: 1 addition & 1 deletion django_mailbox/transports/imap.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def close(self):
try:
self.server.close()
self.server.logout()
except (imaplib.IMAP4.error, OSError) as e:
except (imaplib.IMAP4.error, OSError) as e:
logger.warning(f'Failed to close IMAP connection, ignoring: {e}')
pass

Expand Down

0 comments on commit 6dcded0

Please sign in to comment.