pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.29k stars 1.13k forks source link

"Method '[...]' has no '__doc__' member (no-member)" when using augmented assignment in class body #1078

Closed mwchase closed 4 years ago

mwchase commented 8 years ago

Steps to reproduce

  1. Create a method with a docstring.
  2. Access the method's docstring through its doc member.

    Current behavior

Code executes fine, pylint generates an Error message: "Method '[...]' has no 'doc' member (no-member)"

Expected behavior

Pylint should not generate an error message for the doc member, because it is in fact defined. (Even if there's no docstring, it's still None.)

pylint --version output

No config file found, using default configuration pylint 1.6.4, astroid 1.4.8 Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]

(Edited the title to reflect the reproduction below.)

PCManticore commented 8 years ago

Something as in the following example?

class A:
   def test(self):
        "a"

print(A().test.__doc__)
print(A.test.__doc__)

If so, can you try with pylint@master and astroid@master and let me know if you can reproduce it or not, please?

mwchase commented 8 years ago

I had to modify the code slightly:

class A:
    def test(self):
        "a"
    test.__doc__ += 'b'

print(A().test.__doc__)
print(A.test.__doc__)

pylint --version output

No config file found, using default configuration pylint 2.0.0, astroid 1.5.0 Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]

The precise output differs slightly between the two versions. Both versions ding the assignment and the second print statement, but 1.6.4 also dings the first print statement.