pylint-bot / pylint-unofficial

UNOFFICIAL playground for pylint github migration
0 stars 0 forks source link

Invalid missing-docstring with @property setter, deleter methods #651

Closed pylint-bot closed 8 years ago

pylint-bot commented 9 years ago

Originally reported by: BitBucket: adrian_flanagan


Given the following file, which is based on an example in the python documentation:

#!python
"""Module doc"""
# pylint: disable=locally-disabled,invalid-name,too-few-public-methods

class A(object):
    """Not very useful demo object."""

    def __init__(self):
        self._x = 0

    @property
    def x(self):
        """This docstring on getter applies to property as a whole.
           (https://docs.python.org/3/library/functions.html#property)"""
        return self._x

    @x.setter
    def x(self, new_val):
        self._x = new_val

    @x.deleter
    def x(self):
        del self._x

pylint detects the following errors. However, It should recognize that a property is created, and not flag an error as long as there is a docstring on the getter method.

************* Module temp
C: 18, 4: Missing method docstring (missing-docstring)
C: 22, 4: Missing method docstring (missing-docstring)

pylint-bot commented 9 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


That's true, thanks for the report.

pylint-bot commented 9 years ago

Original comment by Michael Kefeder (BitBucket: multiwave, GitHub: @multiwave?):


One of our developers found that behaviour too, so I fixed it for him, see patch. I have no idea if that is the right way to do it, since it's first time of me looking into pylint source, but this quickhack works.

pylint-bot commented 9 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Thanks! I didn't notice the original patch, sorry about that. It will also need a couple of tests, in order to assure that we won't regress. Would you be willing to submit this as a pull request? If so and if you'll need guidance, just ask and I'll help.

pylint-bot commented 9 years ago

Original comment by Michael Kefeder (BitBucket: multiwave, GitHub: @multiwave?):


reason for the attached patch (@claudiu that's mine, wasn't there before, you didn't overlook anything) was me being too lazy going full fork/branch/push on it ;) Alright pull request is submitted, I think I even connected it somehow to this Issue. Hope that helps.

pylint-bot commented 9 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Ignore missing docstrings for decorated attribute setters and deleters

Closes issue #651.

pylint-bot commented 9 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Ignore missing docstrings for decorated attribute setters and deleters

Closes issue #651.