0

I've decided to improve the quality of my code by running some known working code through pylint. In particular I have a milter using pymilter. Here is the really simple code that I'm running:

#!/usr/bin/python3
"Test Milter"

import Milter

# Configuration

# List of email addresses for which incoming mail should  be rejected:
EMAILS = ('mailinglist1@domain.com', 'mailinglist2@domain.com')
# Socket for milter
SOCKETNAME = 'inet:14201@127.0.0.1'

# End of Configuration

class TestMilter(Milter.Milter):
    "Test Milter"

    def __init__(self):
        self.milter_id = Milter.uniqueID()

    def envrcpt(self, to, *str):
        "Reject mail if the To: address is one of the specified e-mail addresses."
        if any(e in to for e in EMAILS):
            return Milter.REJECT
        return Milter.ACCEPT

if __name__ == "__main__":
    Milter.factory = TestMilter
    Milter.runmilter("test_milter", SOCKETNAME, 240)

Here is the output of pylint -E:

************* Module test_milter
test_milter.py:24:19: E1101: Module 'Milter' has no 'REJECT' member (no-member)
test_milter.py:25:15: E1101: Module 'Milter' has no 'ACCEPT' member (no-member)

I've looked high and low, and simply do not understand why pylint is giving me this output. I don't want to tell it to ignore this particular rule, because it is actually a very useful rule most of the time. Any ideas?

Bintz
  • 784
  • 2
  • 9
  • 22
  • Taking a quick look at the docs, I don't see a `Milter.REJECT` or a `Milter.ACCEPT`. I see `milter.REJECT`, but not `Milter.REJECT`. – user2357112 Apr 14 '20 at 02:44
  • It looks like they're using `from milter import *`, and `milter` is an extension module, so PyLint has no idea about anything brought into `Milter` by that import. – user2357112 Apr 14 '20 at 02:48
  • That makes sense. Any idea of best practices to avoid pylint throwing this error in such a situation? – Bintz Apr 14 '20 at 05:37

0 Answers0