diff options
author | Bruno Daniel <bruno.daniel@blue-yonder.com> | 2015-05-10 14:47:29 +0200 |
---|---|---|
committer | Bruno Daniel <bruno.daniel@blue-yonder.com> | 2015-05-10 14:47:29 +0200 |
commit | 8c33a466ee271bf4667b37ad2a58905da0401f03 (patch) | |
tree | a0418cc0cf88c0c875ed0923efb6e1f9021386c0 /pylint/extensions | |
parent | 9ff3e99e08d2a29056a196f9a953aa40eca23474 (diff) | |
download | pylint-8c33a466ee271bf4667b37ad2a58905da0401f03.tar.gz |
method visit_class is no longer necessary in the checker; auxiliary method _visit_methods_of_class in the unit test
Diffstat (limited to 'pylint/extensions')
-rw-r--r-- | pylint/extensions/check_docs.py | 11 | ||||
-rw-r--r-- | pylint/extensions/test/test_check_docs.py | 24 |
2 files changed, 18 insertions, 17 deletions
diff --git a/pylint/extensions/check_docs.py b/pylint/extensions/check_docs.py index 4092557..06bb994 100644 --- a/pylint/extensions/check_docs.py +++ b/pylint/extensions/check_docs.py @@ -309,17 +309,6 @@ class ParamDocChecker(BaseChecker): return params_with_doc, params_with_type - def visit_class(self, node): - """Called for class definitions. - - :param node: Node for a class definition in the AST - :type node: :class:`astroid.scoped_nodes.Class` - """ - for body_item in node.body: - if (isinstance(body_item, astroid.scoped_nodes.Function) - and hasattr(body_item, 'name')): - self.visit_function(body_item) - def register(linter): """Required method to auto register this checker. diff --git a/pylint/extensions/test/test_check_docs.py b/pylint/extensions/test/test_check_docs.py index c14b3b1..cc8d300 100644 --- a/pylint/extensions/test/test_check_docs.py +++ b/pylint/extensions/test/test_check_docs.py @@ -6,6 +6,7 @@ from __future__ import division, print_function, absolute_import import unittest from astroid import test_utils +import astroid.scoped_nodes from pylint.testutils import CheckerTestCase, Message, set_config from pylint.extensions.check_docs import ParamDocChecker, space_indentation @@ -146,6 +147,17 @@ class ParamDocCheckerTest(CheckerTestCase): ): self.checker.visit_function(node) + def _visit_methods_of_class(self, node): + """Visit all methods of a class node + + :param node: class node + :type node: :class:`astroid.scoped_nodes.Class` + """ + for body_item in node.body: + if (isinstance(body_item, astroid.scoped_nodes.Function) + and hasattr(body_item, 'name')): + self.checker.visit_function(body_item) + def test_missing_method_params_in_sphinx_docstring(self): """Example of a class method with missing parameter documentation in the Sphinx style docstring @@ -172,7 +184,7 @@ class ParamDocCheckerTest(CheckerTestCase): node=method_node, args=('x, y',)) ): - self.checker.visit_class(node) + self._visit_methods_of_class(node) def test_missing_method_params_in_google_docstring(self): """Example of a class method with missing parameter documentation in @@ -201,7 +213,7 @@ class ParamDocCheckerTest(CheckerTestCase): node=method_node, args=('x, y',)) ): - self.checker.visit_class(node) + self._visit_methods_of_class(node) def test_missing_method_params_in_numpy_docstring(self): """Example of a class method with missing parameter documentation in @@ -232,7 +244,7 @@ class ParamDocCheckerTest(CheckerTestCase): node=method_node, args=('x, y',)) ): - self.checker.visit_class(node) + self._visit_methods_of_class(node) def test_existing_func_params_in_sphinx_docstring(self): """Example of a function with correctly documented parameters and @@ -558,7 +570,7 @@ class ParamDocCheckerTest(CheckerTestCase): node=node, args=('x, y',)) ): - self.checker.visit_class(node) + self._visit_methods_of_class(node) def test_constr_params_in_class_google(self): """Example of a class with missing constructor parameter documentation @@ -590,7 +602,7 @@ class ParamDocCheckerTest(CheckerTestCase): node=node, args=('x, y',)) ): - self.checker.visit_class(node) + self._visit_methods_of_class(node) def test_constr_params_in_class_numpy(self): """Example of a class with missing constructor parameter documentation @@ -624,7 +636,7 @@ class ParamDocCheckerTest(CheckerTestCase): node=node, args=('x, y',)) ): - self.checker.visit_class(node) + self._visit_methods_of_class(node) if __name__ == '__main__': |