diff options
author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-01-24 00:27:52 +0200 |
---|---|---|
committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-01-24 00:27:52 +0200 |
commit | 5e3c3acdca5fc311b195b9a5e4b15a336b919819 (patch) | |
tree | 3517aa31e691217dfc30acfe93073e7fb59b0b62 | |
parent | a91879b9668d9d39a9e0d4939217f7d051e47aa5 (diff) | |
download | pylint-5e3c3acdca5fc311b195b9a5e4b15a336b919819.tar.gz |
Don't require a docstring for empty modules. Closes issue #261.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | checkers/base.py | 5 | ||||
-rw-r--r-- | test/messages/func_empty_module.txt | 1 | ||||
-rw-r--r-- | test/unittest_checker_base.py | 7 |
4 files changed, 15 insertions, 2 deletions
@@ -1,6 +1,10 @@ ChangeLog for Pylint ==================== +-- + * Don't require a docstring for empty modules. Closes issue #261. + + 2015-01-16 -- 1.4.1 * Look only in the current function's scope for bad-super-call. diff --git a/checkers/base.py b/checkers/base.py index 750d661..404f9de 100644 --- a/checkers/base.py +++ b/checkers/base.py @@ -1171,6 +1171,11 @@ class DocStringChecker(_BasicChecker): lines = node.body[-1].lineno - node.body[0].lineno + 1 else: lines = 0 + + if node_type == 'module' and not lines: + # If the module has no body, there's no reason + # to require a docstring. + return max_lines = self.config.docstring_min_length if node_type != 'module' and max_lines > -1 and lines < max_lines: diff --git a/test/messages/func_empty_module.txt b/test/messages/func_empty_module.txt index bbc5a0d..0563049 100644 --- a/test/messages/func_empty_module.txt +++ b/test/messages/func_empty_module.txt @@ -1,2 +1 @@ -C: 1: Missing module docstring C: 1: Missing required attribute "__revision__" diff --git a/test/unittest_checker_base.py b/test/unittest_checker_base.py index adf50d8..b74ac5a 100644 --- a/test/unittest_checker_base.py +++ b/test/unittest_checker_base.py @@ -13,10 +13,15 @@ class DocstringTest(CheckerTestCase): CHECKER_CLASS = base.DocStringChecker def test_missing_docstring_module(self): - module = test_utils.build_module("") + module = test_utils.build_module("something") with self.assertAddsMessages(Message('missing-docstring', node=module, args=('module',))): self.checker.visit_module(module) + def test_missing_docstring_emtpy_module(self): + module = test_utils.build_module("") + with self.assertNoMessages(): + self.checker.visit_module(module) + def test_empty_docstring_module(self): module = test_utils.build_module("''''''") with self.assertAddsMessages(Message('empty-docstring', node=module, args=('module',))): |