diff options
author | Michael Kefeder <oss@multiwave.ch> | 2015-11-19 17:20:05 +0100 |
---|---|---|
committer | Michael Kefeder <oss@multiwave.ch> | 2015-11-19 17:20:05 +0100 |
commit | 6f59c12b55765a3cc721864e8882f1e8e49bcb58 (patch) | |
tree | bfa517574e599f0cbb65a26bcbf59a36665cf164 /pylint | |
parent | 2fc6f58d5f5fb890f016283c66e7980fa79beac9 (diff) | |
download | pylint-6f59c12b55765a3cc721864e8882f1e8e49bcb58.tar.gz |
Ignore missing docstrings for decorated attribute setters and deleters
Closes issue #651.
Diffstat (limited to 'pylint')
-rw-r--r-- | pylint/checkers/base.py | 12 | ||||
-rw-r--r-- | pylint/test/functional/missing_docstring.py | 19 |
2 files changed, 31 insertions, 0 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index cc7c786..74a1f64 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -1360,10 +1360,22 @@ class DocStringChecker(_BasicChecker): if self.config.no_docstring_rgx.match(node.name) is None: self._check_docstring('class', node) + @staticmethod + def _is_setter_or_deleter(node): + names = {'setter', 'deleter'} + for decorator in node.decorators.nodes: + if (isinstance(decorator, astroid.Attribute) + and decorator.attrname in names): + return True + return False + @check_messages('missing-docstring', 'empty-docstring') def visit_functiondef(self, node): if self.config.no_docstring_rgx.match(node.name) is None: ftype = node.is_method() and 'method' or 'function' + if node.decorators and self._is_setter_or_deleter(node): + return + if isinstance(node.parent.frame(), astroid.ClassDef): overridden = False confidence = (INFERENCE if has_known_bases(node.parent.frame()) diff --git a/pylint/test/functional/missing_docstring.py b/pylint/test/functional/missing_docstring.py index 2392ebb..2d6f1fd 100644 --- a/pylint/test/functional/missing_docstring.py +++ b/pylint/test/functional/missing_docstring.py @@ -33,3 +33,22 @@ def __sizeof__(): def __mangled():
pass
+
+
+class Property(object):
+ """Don't warn about setters and deleters."""
+
+ def __init__(self):
+ self._value = None
+
+ @property
+ def test(self):
+ """Default docstring for setters and deleters."""
+
+ @test.setter
+ def test(self, value):
+ self._value = value
+
+ @test.deleter
+ def test(self):
+ pass
|