3
0
Fork 0

fix: fix 'no-member' for pylint

This commit is contained in:
Lance Edgar 2025-08-30 20:32:56 -05:00
parent 87af670df6
commit 79bab4f9e1
3 changed files with 16 additions and 16 deletions

View file

@ -22,6 +22,7 @@ enable=anomalous-backslash-in-string,
missing-module-docstring, missing-module-docstring,
no-else-return, no-else-return,
no-self-argument, no-self-argument,
no-member,
possibly-used-before-assignment, possibly-used-before-assignment,
redefined-argument-from-local, redefined-argument-from-local,
redefined-outer-name, redefined-outer-name,

View file

@ -187,15 +187,15 @@ class Message:
self.key = key self.key = key
self.sender = sender self.sender = sender
self.subject = subject self.subject = subject
self.set_recips('to', to) self.to = self.get_recips(to)
self.set_recips('cc', cc) self.cc = self.get_recips(cc)
self.set_recips('bcc', bcc) self.bcc = self.get_recips(bcc)
self.replyto = replyto self.replyto = replyto
self.txt_body = txt_body self.txt_body = txt_body
self.html_body = html_body self.html_body = html_body
self.attachments = attachments or [] self.attachments = attachments or []
def set_recips(self, name, value): # pylint: disable=empty-docstring def get_recips(self, value): # pylint: disable=empty-docstring
""" """ """ """
if value: if value:
if isinstance(value, str): if isinstance(value, str):
@ -204,7 +204,7 @@ class Message:
raise ValueError("must specify a string, tuple or list value") raise ValueError("must specify a string, tuple or list value")
else: else:
value = [] value = []
setattr(self, name, list(value)) return list(value)
def as_string(self): def as_string(self):
""" """

View file

@ -30,28 +30,27 @@ class TestMessage(FileTestCase):
def make_message(self, **kwargs): def make_message(self, **kwargs):
return mod.Message(**kwargs) return mod.Message(**kwargs)
def test_set_recips(self): def test_get_recips(self):
msg = self.make_message() msg = self.make_message()
self.assertEqual(msg.to, [])
# set as list # set as list
msg.set_recips('to', ['sally@example.com']) recips = msg.get_recips(['sally@example.com'])
self.assertEqual(msg.to, ['sally@example.com']) self.assertEqual(recips, ['sally@example.com'])
# set as tuple # set as tuple
msg.set_recips('to', ('barney@example.com',)) recips = msg.get_recips(('barney@example.com',))
self.assertEqual(msg.to, ['barney@example.com']) self.assertEqual(recips, ['barney@example.com'])
# set as string # set as string
msg.set_recips('to', 'wilma@example.com') recips = msg.get_recips('wilma@example.com')
self.assertEqual(msg.to, ['wilma@example.com']) self.assertEqual(recips, ['wilma@example.com'])
# set as null # set as null
msg.set_recips('to', None) recips = msg.get_recips(None)
self.assertEqual(msg.to, []) self.assertEqual(recips, [])
# otherwise error # otherwise error
self.assertRaises(ValueError, msg.set_recips, 'to', {'foo': 'foo@example.com'}) self.assertRaises(ValueError, msg.get_recips, {'foo': 'foo@example.com'})
def test_as_string(self): def test_as_string(self):