diff options
| author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-04-08 21:30:48 +0300 |
|---|---|---|
| committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-04-08 21:30:48 +0300 |
| commit | ee6762700af0dc4beefc23b4b123206b9aa6c74b (patch) | |
| tree | 8f6b24daa9cd4793f99689bd8e204adcf1b333b4 | |
| parent | b93723a8db12e161abc8e2e6c56c50ce9d41e477 (diff) | |
| download | pylint-ee6762700af0dc4beefc23b4b123206b9aa6c74b.tar.gz | |
Don't emit missing-docstring for private functions.
| -rw-r--r-- | ChangeLog | 2 | ||||
| -rw-r--r-- | pylint/checkers/base.py | 2 | ||||
| -rw-r--r-- | pylint/test/functional/missing_docstring.py | 26 | ||||
| -rw-r--r-- | pylint/test/functional/missing_docstring.txt | 3 |
4 files changed, 33 insertions, 0 deletions
@@ -50,6 +50,8 @@ ChangeLog for Pylint * Fix a false positive for bad-reversed-sequence, when a subclass of a `dict` provides a __reversed__ method. + * Don't emit missing-docstring for private functions. + 2015-03-14 -- 1.4.3 diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index 6b9cdac..d50369c 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -1193,6 +1193,8 @@ class DocStringChecker(_BasicChecker): if docstring is None: if not report_missing: return + if node.name.startswith("_"): + return if node.body: lines = node.body[-1].lineno - node.body[0].lineno + 1 else: diff --git a/pylint/test/functional/missing_docstring.py b/pylint/test/functional/missing_docstring.py new file mode 100644 index 0000000..eafacd5 --- /dev/null +++ b/pylint/test/functional/missing_docstring.py @@ -0,0 +1,26 @@ +# [missing-docstring]
+# pylint: disable=too-few-public-methods
+
+def public_documented():
+ """It has a docstring."""
+
+
+def _private_undocumented():
+ # Doesn't need a docstring
+ pass
+
+
+def _private_documented():
+ """It has a docstring."""
+
+
+class ClassDocumented(object):
+ """It has a docstring."""
+
+
+class ClassUndocumented(object): # [missing-docstring]
+ pass
+
+
+def public_undocumented(): # [missing-docstring]
+ pass
diff --git a/pylint/test/functional/missing_docstring.txt b/pylint/test/functional/missing_docstring.txt new file mode 100644 index 0000000..2680319 --- /dev/null +++ b/pylint/test/functional/missing_docstring.txt @@ -0,0 +1,3 @@ +missing-docstring:1::Missing module docstring +missing-docstring:21:ClassUndocumented:Missing class docstring +missing-docstring:25:public_undocumented:Missing function docstring |
