diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2019-09-23 10:04:26 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-09-23 10:04:26 +0200 |
commit | ce2af67d0e96e26c1999e1a53e36cf1460d9d647 (patch) | |
tree | 3cc808b8042118a2f27c9f85a1e39c4dbd7f80d9 | |
parent | 939f91c886deb989ae4c5e2698c0d0d483e7bfec (diff) | |
download | pylint-git-ce2af67d0e96e26c1999e1a53e36cf1460d9d647.tar.gz |
Exempt kwonly arguments when they are annotated from missing-type-doc. Close #3092
-rw-r--r-- | pylint/extensions/docparams.py | 3 | ||||
-rw-r--r-- | tests/extensions/test_check_docs.py | 18 |
2 files changed, 21 insertions, 0 deletions
diff --git a/pylint/extensions/docparams.py b/pylint/extensions/docparams.py index b9b7900de..6d6c9ec1a 100644 --- a/pylint/extensions/docparams.py +++ b/pylint/extensions/docparams.py @@ -459,6 +459,9 @@ class DocstringParameterChecker(BaseChecker): for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) + for index, arg_name in enumerate(arguments_node.kwonlyargs): + if arguments_node.kwonlyargs_annotations[index]: + params_with_type.add(arg_name.name) self._compare_missing_args( params_with_type, diff --git a/tests/extensions/test_check_docs.py b/tests/extensions/test_check_docs.py index 234ff6da4..90ccf6334 100644 --- a/tests/extensions/test_check_docs.py +++ b/tests/extensions/test_check_docs.py @@ -75,6 +75,24 @@ class TestParamDocChecker(CheckerTestCase): ): self.checker.visit_functiondef(node) + def test_missing_type_doc_google_docstring_exempt_kwonly_args(self): + node = astroid.extract_node( + """ + def identifier_kwarg_method(arg1: int, arg2: int, *, value1: str, value2: str): + '''Code to show failure in missing-type-doc + + Args: + arg1: First argument. + arg2: Second argument. + value1: First kwarg. + value2: Second kwarg. + ''' + print("NOTE: It doesn't like anything after the '*'.") + """ + ) + with self.assertNoMessages(): + self.checker.visit_functiondef(node) + def test_missing_func_params_with_annotations_in_google_docstring(self): """Example of a function with missing Google style parameter documentation in the docstring. |