From 79bab4f9e18e360dac48401685a68d4f4f31544e Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 30 Aug 2025 20:32:56 -0500 Subject: [PATCH] fix: fix 'no-member' for pylint --- .pylintrc | 1 + src/wuttjamaican/email.py | 10 +++++----- tests/test_email.py | 21 ++++++++++----------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.pylintrc b/.pylintrc index 486afbc..f1f7f26 100644 --- a/.pylintrc +++ b/.pylintrc @@ -22,6 +22,7 @@ enable=anomalous-backslash-in-string, missing-module-docstring, no-else-return, no-self-argument, + no-member, possibly-used-before-assignment, redefined-argument-from-local, redefined-outer-name, diff --git a/src/wuttjamaican/email.py b/src/wuttjamaican/email.py index f5fce03..77e702b 100644 --- a/src/wuttjamaican/email.py +++ b/src/wuttjamaican/email.py @@ -187,15 +187,15 @@ class Message: self.key = key self.sender = sender self.subject = subject - self.set_recips('to', to) - self.set_recips('cc', cc) - self.set_recips('bcc', bcc) + self.to = self.get_recips(to) + self.cc = self.get_recips(cc) + self.bcc = self.get_recips(bcc) self.replyto = replyto self.txt_body = txt_body self.html_body = html_body 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 isinstance(value, str): @@ -204,7 +204,7 @@ class Message: raise ValueError("must specify a string, tuple or list value") else: value = [] - setattr(self, name, list(value)) + return list(value) def as_string(self): """ diff --git a/tests/test_email.py b/tests/test_email.py index 8cf1623..6e1a72d 100644 --- a/tests/test_email.py +++ b/tests/test_email.py @@ -30,28 +30,27 @@ class TestMessage(FileTestCase): def make_message(self, **kwargs): return mod.Message(**kwargs) - def test_set_recips(self): + def test_get_recips(self): msg = self.make_message() - self.assertEqual(msg.to, []) # set as list - msg.set_recips('to', ['sally@example.com']) - self.assertEqual(msg.to, ['sally@example.com']) + recips = msg.get_recips(['sally@example.com']) + self.assertEqual(recips, ['sally@example.com']) # set as tuple - msg.set_recips('to', ('barney@example.com',)) - self.assertEqual(msg.to, ['barney@example.com']) + recips = msg.get_recips(('barney@example.com',)) + self.assertEqual(recips, ['barney@example.com']) # set as string - msg.set_recips('to', 'wilma@example.com') - self.assertEqual(msg.to, ['wilma@example.com']) + recips = msg.get_recips('wilma@example.com') + self.assertEqual(recips, ['wilma@example.com']) # set as null - msg.set_recips('to', None) - self.assertEqual(msg.to, []) + recips = msg.get_recips(None) + self.assertEqual(recips, []) # 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):