Can't pylint detect unresolved attribute reference?

372 views Asked by At

We've been bit multiple times that pylint did not catch a simple unresolved attribute reference error.

I looked at pylint code but could not immediately find it. IDE like PyCharm can detect it, so it must be possible to detect it in pylint. We are using pylint as a CI job and want to be able to detect this before we merge code.

What pylint settings do I need to enable to catch an error like below?

class A():
    df test_a(self):
         print("A")

a = A()
a.test_b() # this should be caught by pylint.
1

There are 1 answers

0
Pierre.Sassoulas On

What version of pylint are you using ? Both pylint 2.8.2 and mypy 0.812 detect this problem.

With b.py:

class A():
    def test_a(self):
         print("A")

a = A()
a.test_b() # this should be caught by pylint.

pylint b.py:

************* Module b
b.py:2:4: R0201: Method could be a function (no-self-use)
b.py:6:0: E1101: Instance of 'A' has no 'test_b' member; maybe 'test_a'? (no-member)

------------------------------------
Your code has been rated at -2.00/10

mypy b.py:

b.py:6: error: "A" has no attribute "test_b"; maybe "test_a"?
Found 1 error in 1 file (checked 1 source file)