summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-12-07 16:13:55 +0100
committerGitHub <noreply@github.com>2021-12-07 16:13:55 +0100
commit7523ad1c6710ff00ed2d500ed5d9b80c6d9007a7 (patch)
treec578041dab96f5416483c1b012e6f0d6687ae07c
parent71444989a93a6979fd7bd1eab4b6667180e528ad (diff)
downloadpylint-git-7523ad1c6710ff00ed2d500ed5d9b80c6d9007a7.tar.gz
Move tests for Google docstrings from ``TestParamDocChecker`` to functional tests (#5484)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
-rw-r--r--tests/extensions/test_check_docs.py810
-rw-r--r--tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py393
-rw-r--r--tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc1
-rw-r--r--tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.txt26
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_Google.py56
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_Google.txt5
-rw-r--r--tests/functional/ext/docparams/return/missing_return_doc_Google.py100
-rw-r--r--tests/functional/ext/docparams/return/missing_return_doc_Google.txt10
-rw-r--r--tests/functional/ext/docparams/return/missing_return_doc_required_Google.py36
-rw-r--r--tests/functional/ext/docparams/return/missing_return_doc_required_Google.txt5
10 files changed, 626 insertions, 816 deletions
diff --git a/tests/extensions/test_check_docs.py b/tests/extensions/test_check_docs.py
index 0f7f6c252..a5293b821 100644
--- a/tests/extensions/test_check_docs.py
+++ b/tests/extensions/test_check_docs.py
@@ -48,203 +48,6 @@ class TestParamDocChecker(CheckerTestCase):
"docstring_min_length": -1,
}
- def test_missing_func_params_in_google_docstring(self) -> None:
- """Example of a function with missing Google style parameter
- documentation in the docstring
- """
- node = astroid.extract_node(
- """
- def function_foo(x, y, z):
- '''docstring ...
-
- Args:
- x: bla
- z (int): bar
-
- some other stuff
- '''
- pass
- """
- )
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-param-doc", node=node, args=("y",)),
- MessageTest(msg_id="missing-type-doc", node=node, args=("x, y",)),
- ):
- self.checker.visit_functiondef(node)
-
- def test_missing_type_doc_google_docstring_exempt_kwonly_args(self) -> None:
- 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) -> None:
- """Example of a function with missing Google style parameter
- documentation in the docstring.
- """
- node = astroid.extract_node(
- """
- def function_foo(x: int, y: bool, z):
- '''docstring ...
-
- Args:
- x: bla
- y: blah blah
- z (int): bar
-
- some other stuff
- '''
- pass
- """
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
- def test_default_arg_with_annotations_in_google_docstring(self) -> None:
- """Example of a function with missing Google style parameter
- documentation in the docstring.
- """
- node = astroid.extract_node(
- """
- def function_foo(x: int, y: bool, z: int = 786):
- '''docstring ...
-
- Args:
- x: bla
- y: blah blah
- z: bar
-
- some other stuff
- '''
- pass
- """
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
- def test_missing_func_params_with_partial_annotations_in_google_docstring(
- self,
- ) -> None:
- """Example of a function with missing Google style parameter
- documentation in the docstring.
- """
- node = astroid.extract_node(
- """
- def function_foo(x, y: bool, z):
- '''docstring ...
-
- Args:
- x: bla
- y: blah blah
- z (int): bar
-
- some other stuff
- '''
- pass
- """
- )
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-type-doc", node=node, args=("x",))
- ):
- self.checker.visit_functiondef(node)
-
- def test_non_builtin_annotations_in_google_docstring(self) -> None:
- """Example of a function with missing Google style parameter
- documentation in the docstring.
- """
- node = astroid.extract_node(
- """
- def area(bottomleft: Point, topright: Point) -> float:
- '''Calculate area of fake rectangle.
- Args:
- bottomleft: bottom left point of rectangle
- topright: top right point of rectangle
- '''
- pass
- """
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
- def test_non_builtin_annotations_for_returntype_in_google_docstring(self) -> None:
- """Example of a function with missing Google style parameter
- documentation in the docstring.
- """
- node = astroid.extract_node(
- """
- def get_midpoint(bottomleft: Point, topright: Point) -> Point:
- '''Calculate midpoint of fake rectangle.
- Args:
- bottomleft: bottom left point of rectangle
- topright: top right point of rectangle
- '''
- pass
- """
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
- def test_func_params_and_keyword_params_in_google_docstring(self) -> None:
- """Example of a function with Google style parameter split
- in Args and Keyword Args in the docstring
- """
- node = astroid.extract_node(
- """
- def my_func(this, other, that=True):
- '''Prints this, other and that
-
- Args:
- this (str): Printed first
- other (int): Other args
-
- Keyword Args:
- that (bool): Printed second
- '''
- print(this, that, other)
- """
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
- def test_func_params_and_wrong_keyword_params_in_google_docstring(self) -> None:
- """Example of a function with Google style parameter split
- in Args and Keyword Args in the docstring but with wrong keyword args
- """
- node = astroid.extract_node(
- """
- def my_func(this, other, that=True):
- '''Prints this, other and that
-
- Args:
- this (str): Printed first
- other (int): Other args
-
- Keyword Args:
- these (bool): Printed second
- '''
- print(this, that, other)
- """
- )
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-param-doc", node=node, args=("that",)),
- MessageTest(msg_id="missing-type-doc", node=node, args=("that",)),
- MessageTest(msg_id="differing-param-doc", node=node, args=("these",)),
- MessageTest(msg_id="differing-type-doc", node=node, args=("these",)),
- ):
- self.checker.visit_functiondef(node)
-
def test_missing_func_params_in_numpy_docstring(self) -> None:
"""Example of a function with missing NumPy style parameter
documentation in the docstring
@@ -336,31 +139,6 @@ class TestParamDocChecker(CheckerTestCase):
if isinstance(body_item, nodes.FunctionDef) and hasattr(body_item, "name"):
self.checker.visit_functiondef(body_item)
- def test_missing_method_params_in_google_docstring(self) -> None:
- """Example of a class method with missing parameter documentation in
- the Google style docstring
- """
- node = astroid.extract_node(
- """
- class Foo(object):
- def method_foo(self, x, y):
- '''docstring ...
-
- missing parameter documentation
-
- Args:
- x: bla
- '''
- pass
- """
- )
- method_node = node.body[0]
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-param-doc", node=method_node, args=("y",)),
- MessageTest(msg_id="missing-type-doc", node=method_node, args=("x, y",)),
- ):
- self._visit_methods_of_class(node)
-
def test_missing_method_params_in_numpy_docstring(self) -> None:
"""Example of a class method with missing parameter documentation in
the Numpy style docstring
@@ -388,32 +166,6 @@ class TestParamDocChecker(CheckerTestCase):
):
self._visit_methods_of_class(node)
- def test_existing_func_params_in_google_docstring(self) -> None:
- """Example of a function with correctly documented parameters and
- return values (Google style)
- """
- node = astroid.extract_node(
- """
- def function_foo(xarg, yarg, zarg, warg):
- '''function foo ...
-
- Args:
- xarg (int): bla xarg
- yarg (my.qualified.type): bla
- bla yarg
-
- zarg (int): bla zarg
- warg (my.qualified.type): bla warg
-
- Returns:
- float: sum
- '''
- return xarg + yarg
- """
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
def test_existing_func_params_in_numpy_docstring(self) -> None:
"""Example of a function with correctly documented parameters and
return values (Numpy style)
@@ -446,53 +198,6 @@ class TestParamDocChecker(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_functiondef(node)
- def test_wrong_name_of_func_params_in_google_docstring(self) -> None:
- """Example of functions with inconsistent parameter names in the
- signature and in the Google style documentation
- """
- node = astroid.extract_node(
- """
- def function_foo(xarg, yarg, zarg):
- '''function foo ...
-
- Args:
- xarg1 (int): bla xarg
- yarg (float): bla yarg
-
- zarg1 (str): bla zarg
- '''
- return xarg + yarg
- """
- )
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-param-doc", node=node, args=("xarg, zarg",)),
- MessageTest(msg_id="missing-type-doc", node=node, args=("xarg, zarg",)),
- MessageTest(
- msg_id="differing-param-doc", node=node, args=("xarg1, zarg1",)
- ),
- MessageTest(msg_id="differing-type-doc", node=node, args=("xarg1, zarg1",)),
- ):
- self.checker.visit_functiondef(node)
-
- node = astroid.extract_node(
- """
- def function_foo(xarg, yarg):
- '''function foo ...
-
- Args:
- yarg1 (float): bla yarg
-
- For the other parameters, see bla.
- '''
- return xarg + yarg
- """
- )
- with self.assertAddsMessages(
- MessageTest(msg_id="differing-param-doc", node=node, args=("yarg1",)),
- MessageTest(msg_id="differing-type-doc", node=node, args=("yarg1",)),
- ):
- self.checker.visit_functiondef(node)
-
def test_wrong_name_of_func_params_in_numpy_docstring(self) -> None:
"""Example of functions with inconsistent parameter names in the
signature and in the Numpy style documentation
@@ -546,27 +251,6 @@ class TestParamDocChecker(CheckerTestCase):
):
self.checker.visit_functiondef(node)
- def test_see_sentence_for_func_params_in_google_docstring(self) -> None:
- """Example for the usage of "For the other parameters, see" to avoid
- too many repetitions, e.g. in functions or methods adhering to a
- given interface (Google style)
- """
- node = astroid.extract_node(
- """
- def function_foo(xarg, yarg):
- '''function foo ...
-
- Args:
- yarg (float): bla yarg
-
- For the other parameters, see :func:`bla`
- '''
- return xarg + yarg
- """
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
def test_see_sentence_for_func_params_in_numpy_docstring(self) -> None:
"""Example for the usage of "For the other parameters, see" to avoid
too many repetitions, e.g. in functions or methods adhering to a
@@ -590,34 +274,6 @@ class TestParamDocChecker(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_functiondef(node)
- def test_constr_params_in_class_google(self) -> None:
- """Example of a class with missing constructor parameter documentation
- (Google style)
-
- Everything is completely analogous to functions.
- """
- node = astroid.extract_node(
- """
- class ClassFoo(object):
- '''docstring foo
-
- Args:
- y: bla
-
- missing constructor parameter documentation
- '''
-
- def __init__(self, x, y):
- pass
-
- """
- )
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-param-doc", node=node, args=("x",)),
- MessageTest(msg_id="missing-type-doc", node=node, args=("x, y",)),
- ):
- self._visit_methods_of_class(node)
-
def test_constr_params_in_class_numpy(self) -> None:
"""Example of a class with missing constructor parameter documentation
(Numpy style)
@@ -673,36 +329,6 @@ class TestParamDocChecker(CheckerTestCase):
with self.assertNoMessages():
self._visit_methods_of_class(node)
- def test_constr_params_in_init_google(self) -> None:
- """Example of a class with missing constructor parameter documentation
- (Google style)
-
- Everything is completely analogous to functions.
- """
- node = astroid.extract_node(
- """
- class ClassFoo(object):
- def __init__(self, x, y):
- '''docstring foo constructor
-
- Args:
- y: bla
-
- missing constructor parameter documentation
- '''
- pass
-
- """
- )
- constructor_node = node.body[0]
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-param-doc", node=constructor_node, args=("x",)),
- MessageTest(
- msg_id="missing-type-doc", node=constructor_node, args=("x, y",)
- ),
- ):
- self._visit_methods_of_class(node)
-
def test_constr_params_in_init_numpy(self) -> None:
"""Example of a class with missing constructor parameter documentation
(Numpy style)
@@ -773,50 +399,6 @@ class TestParamDocChecker(CheckerTestCase):
with self.assertNoMessages():
self._visit_methods_of_class(node)
- def test_constr_params_in_class_and_init_google(self) -> None:
- """Example of a class with missing constructor parameter documentation
- in both the init docstring and the class docstring
- (Google style)
-
- Everything is completely analogous to functions.
- """
- node = astroid.extract_node(
- """
- class ClassFoo(object):
- '''docstring foo
-
- Args:
- y: bla
-
- missing constructor parameter documentation
- '''
-
- def __init__(self, x, y):
- '''docstring foo
-
- Args:
- y: bla
-
- missing constructor parameter documentation
- '''
- pass
-
- """
- )
- constructor_node = node.body[0]
- with self.assertAddsMessages(
- MessageTest(
- msg_id="multiple-constructor-doc", node=node, args=(node.name,)
- ),
- MessageTest(msg_id="missing-param-doc", node=node, args=("x",)),
- MessageTest(msg_id="missing-type-doc", node=node, args=("x, y",)),
- MessageTest(msg_id="missing-param-doc", node=constructor_node, args=("x",)),
- MessageTest(
- msg_id="missing-type-doc", node=constructor_node, args=("x, y",)
- ),
- ):
- self._visit_methods_of_class(node)
-
def test_constr_params_in_class_and_init_numpy(self) -> None:
"""Example of a class with missing constructor parameter documentation
in both the init docstring and the class docstring
@@ -884,48 +466,6 @@ class TestParamDocChecker(CheckerTestCase):
):
self.checker.visit_functiondef(node)
- def test_warns_missing_args_google(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(named_arg, *args):
- """The docstring
-
- Args:
- named_arg (object): Returned
-
- Returns:
- object or None: Maybe named_arg
- """
- if args:
- return named_arg
- '''
- )
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-param-doc", node=node, args=("*args",))
- ):
- self.checker.visit_functiondef(node)
-
- def test_warns_missing_kwargs_google(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(named_arg, **kwargs):
- """The docstring
-
- Args:
- named_arg (object): Returned
-
- Returns:
- object or None: Maybe named_arg
- """
- if kwargs:
- return named_arg
- '''
- )
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-param-doc", node=node, args=("**kwargs",))
- ):
- self.checker.visit_functiondef(node)
-
def test_warns_missing_args_numpy(self) -> None:
node = astroid.extract_node(
'''
@@ -976,46 +516,6 @@ class TestParamDocChecker(CheckerTestCase):
):
self.checker.visit_functiondef(node)
- def test_finds_args_without_type_google(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(named_arg, *args):
- """The docstring
-
- Args:
- named_arg (object): Returned
- *args: Optional arguments
-
- Returns:
- object or None: Maybe named_arg
- """
- if args:
- return named_arg
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
- def test_finds_kwargs_without_type_google(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(named_arg, **kwargs):
- """The docstring
-
- Args:
- named_arg (object): Returned
- **kwargs: Keyword arguments
-
- Returns:
- object or None: Maybe named_arg
- """
- if kwargs:
- return named_arg
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
def test_finds_args_without_type_numpy(self) -> None:
node = astroid.extract_node(
'''
@@ -1047,26 +547,6 @@ class TestParamDocChecker(CheckerTestCase):
):
self.checker.visit_functiondef(node)
- def test_finds_args_with_xref_type_google(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(named_arg, **kwargs):
- """The docstring
-
- Args:
- named_arg (`example.value`): Returned
- **kwargs: Keyword arguments
-
- Returns:
- `example.value`: Maybe named_arg
- """
- if kwargs:
- return named_arg
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
def test_finds_args_with_xref_type_numpy(self) -> None:
node = astroid.extract_node(
'''
@@ -1117,14 +597,11 @@ class TestParamDocChecker(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_functiondef(node)
- CONTAINER_TYPES = [
+ COMPLEX_TYPES = [
"dict(str,str)",
"dict[str,str]",
"tuple(int)",
"list[tokenize.TokenInfo]",
- ]
-
- COMPLEX_TYPES = CONTAINER_TYPES + [
"dict(str, str)",
"dict[str, str]",
"int or str",
@@ -1134,25 +611,6 @@ class TestParamDocChecker(CheckerTestCase):
]
@pytest.mark.parametrize("complex_type", COMPLEX_TYPES)
- def test_finds_multiple_types_google(self, complex_type):
- node = astroid.extract_node(
- f'''
- def my_func(named_arg):
- """The docstring
-
- Args:
- named_arg ({complex_type}): Returned
-
- Returns:
- {complex_type}: named_arg
- """
- return named_arg
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
- @pytest.mark.parametrize("complex_type", COMPLEX_TYPES)
def test_finds_multiple_types_numpy(self, complex_type):
node = astroid.extract_node(
f'''
@@ -1175,29 +633,6 @@ class TestParamDocChecker(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_functiondef(node)
- def test_ignores_optional_specifier_google(self) -> None:
- node = astroid.extract_node(
- '''
- def do_something(param1, param2, param3=(), param4=[], param5=[], param6=True):
- """Do something.
-
- Args:
- param1 (str): Description.
- param2 (dict(str, int)): Description.
- param3 (tuple(str), optional): Defaults to empty. Description.
- param4 (List[str], optional): Defaults to empty. Description.
- param5 (list[tuple(str)], optional): Defaults to empty. Description.
- param6 (bool, optional): Defaults to True. Description.
-
- Returns:
- int: Description.
- """
- return param1, param2, param3, param4, param5, param6
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
def test_ignores_optional_specifier_numpy(self) -> None:
node = astroid.extract_node(
'''
@@ -1239,40 +674,6 @@ class TestParamDocChecker(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_functiondef(node)
- def test_finds_missing_raises_from_setter_google(self) -> None:
- """Example of a setter having missing raises documentation in
- the Google style docstring of the property
- """
- property_node, node = astroid.extract_node(
- """
- class Foo(object):
- @property
- def foo(self): #@
- '''int: docstring
-
- Include a "Raises" section so that this is identified
- as a Google docstring and not a Numpy docstring.
-
- Raises:
- RuntimeError: Always
- '''
- raise RuntimeError()
- return 10
-
- @foo.setter
- def foo(self, value):
- raise AttributeError() #@
- """
- )
- with self.assertAddsMessages(
- MessageTest(
- msg_id="missing-raises-doc",
- node=property_node,
- args=("AttributeError",),
- )
- ):
- self.checker.visit_raise(node)
-
def test_finds_missing_raises_from_setter_numpy(self) -> None:
"""Example of a setter having missing raises documentation in
the Numpy style docstring of the property
@@ -1309,42 +710,6 @@ class TestParamDocChecker(CheckerTestCase):
):
self.checker.visit_raise(node)
- def test_finds_missing_raises_from_setter_google_2(self) -> None:
- """Example of a setter having missing raises documentation in
- its own Google style docstring of the property
- """
- setter_node, node = astroid.extract_node(
- """
- class Foo(object):
- @property
- def foo(self):
- '''int: docstring ...
-
- Raises:
- RuntimeError: Always
- '''
- raise RuntimeError()
- return 10
-
- @foo.setter
- def foo(self, value): #@
- '''setter docstring ...
-
- Raises:
- RuntimeError: Never
- '''
- if True:
- raise AttributeError() #@
- raise RuntimeError()
- """
- )
- with self.assertAddsMessages(
- MessageTest(
- msg_id="missing-raises-doc", node=setter_node, args=("AttributeError",)
- )
- ):
- self.checker.visit_raise(node)
-
def test_finds_missing_raises_from_setter_numpy_2(self) -> None:
"""Example of a setter having missing raises documentation in
its own Numpy style docstring of the property
@@ -1385,27 +750,6 @@ class TestParamDocChecker(CheckerTestCase):
):
self.checker.visit_raise(node)
- def test_finds_property_return_type_google(self) -> None:
- """Example of a property having return documentation in
- a Google style docstring
- """
- node = astroid.extract_node(
- """
- class Foo(object):
- @property
- def foo(self): #@
- '''int: docstring ...
-
- Raises:
- RuntimeError: Always
- '''
- raise RuntimeError()
- return 10
- """
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
def test_finds_property_return_type_numpy(self) -> None:
"""Example of a property having return documentation in
a numpy style docstring
@@ -1429,51 +773,6 @@ class TestParamDocChecker(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_functiondef(node)
- def test_finds_annotation_property_return_type_google(self) -> None:
- """Example of a property having return documentation in
- a Google style docstring
- """
- _, node = astroid.extract_node(
- """
- class Foo(object):
- @property
- def foo(self) -> int: #@
- '''docstring ...
-
- Raises:
- RuntimeError: Always
- '''
- raise RuntimeError()
- return 10 #@
- """
- )
- with self.assertNoMessages():
- self.checker.visit_return(node)
-
- @set_config(accept_no_return_doc="no")
- def test_finds_missing_property_return_type_google(self) -> None:
- """Example of a property having return documentation in
- a Google style docstring
- """
- property_node, node = astroid.extract_node(
- """
- class Foo(object):
- @property
- def foo(self): #@
- '''docstring ...
-
- Raises:
- RuntimeError: Always
- '''
- raise RuntimeError()
- return 10 #@
- """
- )
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-return-type-doc", node=property_node)
- ):
- self.checker.visit_return(node)
-
@set_config(accept_no_return_doc="no")
def test_finds_missing_property_return_type_numpy(self) -> None:
"""Example of a property having return documentation in
@@ -1501,30 +800,6 @@ class TestParamDocChecker(CheckerTestCase):
self.checker.visit_return(node)
@set_config(accept_no_return_doc="no")
- def test_ignores_non_property_return_type_google(self) -> None:
- """Example of a class function trying to use `type` as return
- documentation in a Google style docstring
- """
- func_node, node = astroid.extract_node(
- """
- class Foo(object):
- def foo(self): #@
- '''int: docstring ...
-
- Raises:
- RuntimeError: Always
- '''
- raise RuntimeError()
- return 10 #@
- """
- )
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-return-doc", node=func_node),
- MessageTest(msg_id="missing-return-type-doc", node=func_node),
- ):
- self.checker.visit_return(node)
-
- @set_config(accept_no_return_doc="no")
def test_ignores_non_property_return_type_numpy(self) -> None:
"""Example of a class function trying to use `type` as return
documentation in a numpy style docstring
@@ -1575,27 +850,6 @@ class TestParamDocChecker(CheckerTestCase):
):
self.checker.visit_return(node)
- def test_ignores_return_in_abstract_method_google(self) -> None:
- """Example of an abstract method documenting the return type that an
- implementation should return.
- """
- node = astroid.extract_node(
- """
- import abc
- class Foo(object):
- @abc.abstractmethod
- def foo(self): #@
- '''docstring ...
-
- Returns:
- int: Ten
- '''
- return 10
- """
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
def test_ignores_return_in_abstract_method_numpy(self) -> None:
"""Example of an abstract method documenting the return type that an
implementation should return.
@@ -1619,25 +873,6 @@ class TestParamDocChecker(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_functiondef(node)
- def test_ignores_return_in_abstract_method_google_2(self) -> None:
- """Example of a method documenting the return type that an
- implementation should return.
- """
- node = astroid.extract_node(
- """
- class Foo(object):
- def foo(self, arg): #@
- '''docstring ...
-
- Args:
- arg (int): An argument.
- '''
- raise NotImplementedError()
- """
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
def test_ignores_return_in_abstract_method_numpy_2(self) -> None:
"""Example of a method documenting the return type that an
implementation should return.
@@ -1659,25 +894,6 @@ class TestParamDocChecker(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_functiondef(node)
- def test_ignores_ignored_argument_names_google(self) -> None:
- """Example of a method documenting the return type that an
- implementation should return.
- """
- node = astroid.extract_node(
- """
- class Foo(object):
- def foo(self, arg, _): #@
- '''docstring ...
-
- Args:
- arg (int): An argument.
- '''
- pass
- """
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
def test_ignores_ignored_argument_names_numpy(self) -> None:
"""Example of a method documenting the return type that an
implementation should return.
@@ -1699,30 +915,6 @@ class TestParamDocChecker(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_functiondef(node)
- def test_useless_docs_ignored_argument_names_google(self) -> None:
- """Example of a method documenting the return type that an
- implementation should return.
- """
- node = astroid.extract_node(
- """
- class Foo(object):
- def foo(self, arg, _, _ignored): #@
- '''docstring ...
-
- Args:
- arg (int): An argument.
- _ (float): Another argument.
- _ignored: Ignored argument.
- '''
- pass
- """
- )
- with self.assertAddsMessages(
- MessageTest(msg_id="useless-type-doc", node=node, args=("_",)),
- MessageTest(msg_id="useless-param-doc", node=node, args=("_, _ignored",)),
- ):
- self.checker.visit_functiondef(node)
-
def test_useless_docs_ignored_argument_names_numpy(self) -> None:
"""Example of a method documenting the return type that an
implementation should return.
diff --git a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py
index 0e5bc8e4f..6e291ce83 100644
--- a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py
+++ b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py
@@ -4,7 +4,10 @@ with accept-no-param-doc = no
Styleguide:
https://google.github.io/styleguide/pyguide.html#doc-function-args
"""
-# pylint: disable=invalid-name
+# pylint: disable=invalid-name, unused-argument, undefined-variable
+# pylint: disable=line-too-long, too-few-public-methods, missing-class-docstring
+# pylint: disable=missing-function-docstring, function-redefined, inconsistent-return-statements
+# pylint: disable=dangerous-default-value, too-many-arguments
def test_multi_line_parameters(param: int) -> None:
@@ -16,3 +19,391 @@ def test_multi_line_parameters(param: int) -> None:
a description
"""
print(param)
+
+
+def test_missing_func_params_in_google_docstring( # [missing-param-doc, missing-type-doc]
+ x, y, z
+):
+ """Example of a function with missing Google style parameter
+ documentation in the docstring
+
+ Args:
+ x: bla
+ z (int): bar
+
+ some other stuff
+ """
+
+
+def test_missing_func_params_with_annotations_in_google_docstring(x: int, y: bool, z):
+ """Example of a function with missing Google style parameter
+ documentation in the docstring.
+
+ Args:
+ x: bla
+ y: blah blah
+ z (int): bar
+
+ some other stuff
+ """
+
+
+def test_missing_type_doc_google_docstring_exempt_kwonly_args(
+ 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 '*'.")
+
+
+def test_default_arg_with_annotations_in_google_docstring(
+ x: int, y: bool, z: int = 786
+):
+ """Example of a function with missing Google style parameter
+ documentation in the docstring.
+
+ Args:
+ x: bla
+ y: blah blah
+ z: bar
+
+ some other stuff
+ """
+
+
+def test_missing_func_params_with_partial_annotations_in_google_docstring( # [missing-type-doc]
+ x, y: bool, z
+):
+ """Example of a function with missing Google style parameter
+ documentation in the docstring.
+
+ Args:
+ x: bla
+ y: blah blah
+ z (int): bar
+
+ some other stuff
+ """
+
+
+def test_non_builtin_annotations_in_google_docstring(
+ bottomleft: Point, topright: Point
+) -> float:
+ """Example of a function with missing Google style parameter
+ documentation in the docstring.
+ Args:
+ bottomleft: bottom left point of rectangle
+ topright: top right point of rectangle
+ """
+
+
+def test_non_builtin_annotations_for_returntype_in_google_docstring(bottomleft: Point, topright: Point) -> Point:
+ """Example of a function with missing Google style parameter
+ documentation in the docstring.
+ Args:
+ bottomleft: bottom left point of rectangle
+ topright: top right point of rectangle
+ """
+
+
+def test_func_params_and_keyword_params_in_google_docstring(this, other, that=True):
+ """Example of a function with Google style parameter split
+ in Args and Keyword Args in the docstring
+
+ Args:
+ this (str): Printed first
+ other (int): Other args
+
+ Keyword Args:
+ that (bool): Printed second
+ """
+ print(this, that, other)
+
+
+def test_func_params_and_wrong_keyword_params_in_google_docstring( # [missing-param-doc, missing-type-doc, differing-param-doc, differing-type-doc]
+ this, other, that=True
+):
+ """Example of a function with Google style parameter split
+ in Args and Keyword Args in the docstring but with wrong keyword args
+
+ Args:
+ this (str): Printed first
+ other (int): Other args
+
+ Keyword Args:
+ these (bool): Printed second
+ """
+ print(this, that, other)
+
+
+class Foo:
+ def test_missing_method_params_in_google_docstring( # [missing-param-doc, missing-type-doc]
+ self, x, y
+ ):
+ """Example of a class method with missing parameter documentation in
+ the Google style docstring
+
+ missing parameter documentation
+
+ Args:
+ x: bla
+ """
+
+
+def test_existing_func_params_in_google_docstring(xarg, yarg, zarg, warg):
+ """Example of a function with correctly documented parameters and
+ return values (Google style)
+
+ Args:
+ xarg (int): bla xarg
+ yarg (my.qualified.type): bla
+ bla yarg
+
+ zarg (int): bla zarg
+ warg (my.qualified.type): bla warg
+
+ Returns:
+ float: sum
+ """
+ return xarg + yarg
+
+
+def test_wrong_name_of_func_params_in_google_docstring_one( # [missing-param-doc, missing-type-doc, differing-param-doc, differing-type-doc]
+ xarg, yarg, zarg
+):
+ """Example of functions with inconsistent parameter names in the
+ signature and in the Google style documentation
+
+ Args:
+ xarg1 (int): bla xarg
+ yarg (float): bla yarg
+
+ zarg1 (str): bla zarg
+ """
+ return xarg + yarg
+
+
+def test_wrong_name_of_func_params_in_google_docstring_two( # [differing-param-doc, differing-type-doc]
+ xarg, yarg
+):
+ """Example of functions with inconsistent parameter names in the
+ signature and in the Google style documentation
+
+ Args:
+ yarg1 (float): bla yarg
+
+ For the other parameters, see bla.
+ """
+ return xarg + yarg
+
+
+def test_see_sentence_for_func_params_in_google_docstring(xarg, yarg):
+ """Example for the usage of "For the other parameters, see" to avoid
+ too many repetitions, e.g. in functions or methods adhering to a
+ given interface (Google style)
+
+ Args:
+ yarg (float): bla yarg
+
+ For the other parameters, see :func:`bla`
+ """
+ return xarg + yarg
+
+
+class ClassFoo: # [missing-param-doc, missing-type-doc]
+ """test_constr_params_in_class_google
+ Example of a class with missing constructor parameter documentation
+ (Google style)
+
+ Everything is completely analogous to functions.
+
+ Args:
+ y: bla
+
+ missing constructor parameter documentation
+ """
+
+ def __init__(self, x, y):
+ pass
+
+
+class ClassFoo:
+ def __init__(self, x, y): # [missing-param-doc, missing-type-doc]
+ """test_constr_params_in_init_google
+ Example of a class with missing constructor parameter documentation
+ (Google style)
+
+ Args:
+ y: bla
+
+ missing constructor parameter documentation
+ """
+
+
+class ClassFoo: # [multiple-constructor-doc,missing-param-doc, missing-type-doc]
+ """test_constr_params_in_class_and_init_google
+ Example of a class with missing constructor parameter documentation
+ in both the init docstring and the class docstring
+ (Google style)
+
+ Everything is completely analogous to functions.
+
+ Args:
+ y: bla
+
+ missing constructor parameter documentation
+ """
+
+ def __init__(self, x, y): # [missing-param-doc, missing-type-doc]
+ """docstring foo
+
+ Args:
+ y: bla
+
+ missing constructor parameter documentation
+ """
+
+
+def test_warns_missing_args_google(named_arg, *args): # [missing-param-doc]
+ """The docstring
+
+ Args:
+ named_arg (object): Returned
+
+ Returns:
+ object or None: Maybe named_arg
+ """
+ if args:
+ return named_arg
+
+
+def test_warns_missing_kwargs_google(named_arg, **kwargs): # [missing-param-doc]
+ """The docstring
+
+ Args:
+ named_arg (object): Returned
+
+ Returns:
+ object or None: Maybe named_arg
+ """
+ if kwargs:
+ return named_arg
+
+
+def test_finds_args_without_type_google(named_arg, *args):
+ """The docstring
+
+ Args:
+ named_arg (object): Returned
+ *args: Optional arguments
+
+ Returns:
+ object or None: Maybe named_arg
+ """
+ if args:
+ return named_arg
+
+
+def test_finds_kwargs_without_type_google(named_arg, **kwargs):
+ """The docstring
+
+ Args:
+ named_arg (object): Returned
+ **kwargs: Keyword arguments
+
+ Returns:
+ object or None: Maybe named_arg
+ """
+ if kwargs:
+ return named_arg
+
+
+def test_finds_args_with_xref_type_google(named_arg, **kwargs):
+ """The docstring
+
+ Args:
+ named_arg (`example.value`): Returned
+ **kwargs: Keyword arguments
+
+ Returns:
+ `example.value`: Maybe named_arg
+ """
+ if kwargs:
+ return named_arg
+
+
+def test_ignores_optional_specifier_google(
+ param1, param2, param3=(), param4=[], param5=[], param6=True
+):
+ """Do something.
+
+ Args:
+ param1 (str): Description.
+ param2 (dict(str, int)): Description.
+ param3 (tuple(str), optional): Defaults to empty. Description.
+ param4 (List[str], optional): Defaults to empty. Description.
+ param5 (list[tuple(str)], optional): Defaults to empty. Description.
+ param6 (bool, optional): Defaults to True. Description.
+
+ Returns:
+ int: Description.
+ """
+ return param1, param2, param3, param4, param5, param6
+
+
+def test_finds_multiple_complex_types_google(
+ named_arg_one,
+ named_arg_two,
+ named_arg_three,
+ named_arg_four,
+ named_arg_five,
+ named_arg_six,
+ named_arg_seven,
+ named_arg_eight,
+ named_arg_nine,
+ named_arg_ten,
+):
+ """The google docstring
+
+ Args:
+ named_arg_one (dict(str, str)): Returned
+ named_arg_two (dict[str, str]): Returned
+ named_arg_three (int or str): Returned
+ named_arg_four (tuple(int or str)): Returned
+ named_arg_five (tuple(int) or list(int)): Returned
+ named_arg_six (tuple(int or str) or list(int or str)): Returned
+ named_arg_seven (dict(str,str)): Returned
+ named_arg_eight (dict[str,str]): Returned
+ named_arg_nine (tuple(int)): Returned
+ named_arg_ten (list[tokenize.TokenInfo]): Returned
+
+ Returns:
+ dict(str, str): named_arg_one
+ dict[str, str]: named_arg_two
+ int or str: named_arg_three
+ tuple(int or str): named_arg_four
+ tuple(int) or list(int): named_arg_five
+ tuple(int or str) or list(int or str): named_arg_six
+ dict(str,str): named_arg_seven
+ dict[str,str]: named_arg_eight
+ tuple(int): named_arg_nine
+ list[tokenize.TokenInfo]: named_arg_ten
+ """
+ return (
+ named_arg_one,
+ named_arg_two,
+ named_arg_three,
+ named_arg_four,
+ named_arg_five,
+ named_arg_six,
+ named_arg_seven,
+ named_arg_eight,
+ named_arg_nine,
+ named_arg_ten,
+ )
diff --git a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc
index dd77ffed4..24cdf9ada 100644
--- a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc
+++ b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc
@@ -4,3 +4,4 @@ load-plugins = pylint.extensions.docparams
[BASIC]
accept-no-param-doc=no
docstring-min-length: -1
+no-docstring-rgx=^$
diff --git a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.txt b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.txt
new file mode 100644
index 000000000..6efbd6b1c
--- /dev/null
+++ b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.txt
@@ -0,0 +1,26 @@
+missing-param-doc:24:0:35:7:test_missing_func_params_in_google_docstring:"""y"" missing in parameter documentation":UNDEFINED
+missing-type-doc:24:0:35:7:test_missing_func_params_in_google_docstring:"""x, y"" missing in parameter type documentation":UNDEFINED
+missing-type-doc:80:0:92:7:test_missing_func_params_with_partial_annotations_in_google_docstring:"""x"" missing in parameter type documentation":UNDEFINED
+differing-param-doc:129:0:142:28:test_func_params_and_wrong_keyword_params_in_google_docstring:"""these"" differing in parameter documentation":UNDEFINED
+differing-type-doc:129:0:142:28:test_func_params_and_wrong_keyword_params_in_google_docstring:"""these"" differing in parameter type documentation":UNDEFINED
+missing-param-doc:129:0:142:28:test_func_params_and_wrong_keyword_params_in_google_docstring:"""that"" missing in parameter documentation":UNDEFINED
+missing-type-doc:129:0:142:28:test_func_params_and_wrong_keyword_params_in_google_docstring:"""that"" missing in parameter type documentation":UNDEFINED
+missing-param-doc:146:4:156:11:Foo.test_missing_method_params_in_google_docstring:"""y"" missing in parameter documentation":UNDEFINED
+missing-type-doc:146:4:156:11:Foo.test_missing_method_params_in_google_docstring:"""x, y"" missing in parameter type documentation":UNDEFINED
+differing-param-doc:177:0:189:22:test_wrong_name_of_func_params_in_google_docstring_one:"""xarg1, zarg1"" differing in parameter documentation":UNDEFINED
+differing-type-doc:177:0:189:22:test_wrong_name_of_func_params_in_google_docstring_one:"""xarg1, zarg1"" differing in parameter type documentation":UNDEFINED
+missing-param-doc:177:0:189:22:test_wrong_name_of_func_params_in_google_docstring_one:"""xarg, zarg"" missing in parameter documentation":UNDEFINED
+missing-type-doc:177:0:189:22:test_wrong_name_of_func_params_in_google_docstring_one:"""xarg, zarg"" missing in parameter type documentation":UNDEFINED
+differing-param-doc:192:0:203:22:test_wrong_name_of_func_params_in_google_docstring_two:"""yarg1"" differing in parameter documentation":UNDEFINED
+differing-type-doc:192:0:203:22:test_wrong_name_of_func_params_in_google_docstring_two:"""yarg1"" differing in parameter type documentation":UNDEFINED
+missing-param-doc:219:0:233:12:ClassFoo:"""x"" missing in parameter documentation":UNDEFINED
+missing-type-doc:219:0:233:12:ClassFoo:"""x, y"" missing in parameter type documentation":UNDEFINED
+missing-param-doc:237:4:246:11:ClassFoo.__init__:"""x"" missing in parameter documentation":UNDEFINED
+missing-type-doc:237:4:246:11:ClassFoo.__init__:"""x, y"" missing in parameter type documentation":UNDEFINED
+missing-param-doc:249:0:270:11:ClassFoo:"""x"" missing in parameter documentation":UNDEFINED
+missing-type-doc:249:0:270:11:ClassFoo:"""x, y"" missing in parameter type documentation":UNDEFINED
+multiple-constructor-doc:249:0:270:11:ClassFoo:"""ClassFoo"" has constructor parameters documented in class and __init__":UNDEFINED
+missing-param-doc:263:4:270:11:ClassFoo.__init__:"""x"" missing in parameter documentation":UNDEFINED
+missing-type-doc:263:4:270:11:ClassFoo.__init__:"""x, y"" missing in parameter type documentation":UNDEFINED
+missing-param-doc:273:0:283:24:test_warns_missing_args_google:"""*args"" missing in parameter documentation":UNDEFINED
+missing-param-doc:286:0:296:24:test_warns_missing_kwargs_google:"""**kwargs"" missing in parameter documentation":UNDEFINED
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_Google.py b/tests/functional/ext/docparams/raise/missing_raises_doc_Google.py
index ca261ff42..22dbcadaa 100644
--- a/tests/functional/ext/docparams/raise/missing_raises_doc_Google.py
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_Google.py
@@ -1,6 +1,6 @@
"""Tests for missing-raises-doc and missing-raises-type-doc for Google style docstrings"""
# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
-# pylint: disable=unused-argument, import-outside-toplevel, import-error, try-except-raise
+# pylint: disable=unused-argument, import-outside-toplevel, import-error, try-except-raise, too-few-public-methods
def test_find_missing_google_raises(self): # [missing-raises-doc]
@@ -136,3 +136,57 @@ def test_ignores_caught_google_raises(self):
pass
raise NameError("hi")
+
+
+class Foo:
+ """test_finds_missing_raises_from_setter_google
+ Example of a setter having missing raises documentation in
+ the Google style docstring of the property
+ """
+
+ @property
+ def foo_method(self): # [missing-raises-doc]
+ """int: docstring
+
+ Include a "Raises" section so that this is identified
+ as a Google docstring and not a Numpy docstring.
+
+ Raises:
+ RuntimeError: Always
+ """
+ raise RuntimeError()
+ return 10 # [unreachable]
+
+ @foo_method.setter
+ def foo_method(self, value):
+ print(self)
+ raise AttributeError()
+
+
+class Foo:
+ """test_finds_missing_raises_from_setter_google_2
+ Example of a setter having missing raises documentation in
+ its own Google style docstring of the property.
+ """
+
+ @property
+ def foo_method(self):
+ """int: docstring ...
+
+ Raises:
+ RuntimeError: Always
+ """
+ raise RuntimeError()
+ return 10 # [unreachable]
+
+ @foo_method.setter
+ def foo_method(self, value): # [missing-raises-doc]
+ """setter docstring ...
+
+ Raises:
+ RuntimeError: Never
+ """
+ print(self)
+ if True: # [using-constant-test]
+ raise AttributeError()
+ raise RuntimeError()
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_Google.txt b/tests/functional/ext/docparams/raise/missing_raises_doc_Google.txt
index 17fbc279d..0ac950559 100644
--- a/tests/functional/ext/docparams/raise/missing_raises_doc_Google.txt
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_Google.txt
@@ -7,3 +7,8 @@ unreachable:95:4:95:30:test_find_multiple_google_raises:Unreachable code:UNDEFIN
unreachable:96:4:96:27:test_find_multiple_google_raises:Unreachable code:UNDEFINED
missing-raises-doc:99:0:110:25:test_find_rethrown_google_raises:"""RuntimeError"" not documented as being raised":UNDEFINED
missing-raises-doc:113:0:124:25:test_find_rethrown_google_multiple_raises:"""RuntimeError, ValueError"" not documented as being raised":UNDEFINED
+missing-raises-doc:148:4:158:17:Foo.foo_method:"""AttributeError"" not documented as being raised":UNDEFINED
+unreachable:158:8:158:17:Foo.foo_method:Unreachable code:UNDEFINED
+unreachable:180:8:180:17:Foo.foo_method:Unreachable code:UNDEFINED
+missing-raises-doc:183:4:192:28:Foo.foo_method:"""AttributeError"" not documented as being raised":UNDEFINED
+using-constant-test:190:8:191:34:Foo.foo_method:Using a conditional statement with a constant value:UNDEFINED
diff --git a/tests/functional/ext/docparams/return/missing_return_doc_Google.py b/tests/functional/ext/docparams/return/missing_return_doc_Google.py
index ba530484b..498dbf119 100644
--- a/tests/functional/ext/docparams/return/missing_return_doc_Google.py
+++ b/tests/functional/ext/docparams/return/missing_return_doc_Google.py
@@ -1,6 +1,7 @@
"""Tests for missing-return-doc and missing-return-type-doc for Google style docstrings"""
# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
-# pylint: disable=unused-argument
+# pylint: disable=unused-argument, too-few-public-methods, unnecessary-pass
+import abc
def my_func(self):
@@ -75,3 +76,100 @@ def my_func(self):
if a_func():
return None
return 1
+
+
+class Foo:
+ """test_finds_property_return_type_google
+ Example of a property having return documentation in
+ a Google style docstring
+ """
+
+ @property
+ def foo_method(self):
+ """int: docstring ...
+
+ Raises:
+ RuntimeError: Always
+ """
+ raise RuntimeError()
+ return 10 # [unreachable]
+
+
+class Foo:
+ """test_finds_annotation_property_return_type_google
+ Example of a property having return documentation in
+ a Google style docstring
+ """
+
+ @property
+ def foo_method(self) -> int:
+ """docstring ...
+
+ Raises:
+ RuntimeError: Always
+ """
+ raise RuntimeError()
+ return 10 # [unreachable]
+
+
+class Foo:
+ """test_ignores_return_in_abstract_method_google
+ Example of an abstract method documenting the return type that an
+ implementation should return.
+ """
+
+ @abc.abstractmethod
+ def foo_method(self):
+ """docstring ...
+
+ Returns:
+ int: Ten
+ """
+ return 10
+
+
+class Foo:
+ """test_ignores_return_in_abstract_method_google_2
+ Example of a method documenting the return type that an
+ implementation should return.
+ """
+
+ def foo_method(self, arg):
+ """docstring ...
+
+ Args:
+ arg (int): An argument.
+ """
+ raise NotImplementedError()
+
+
+class Foo:
+ """test_ignores_ignored_argument_names_google
+ Example of a method documenting the return type that an
+ implementation should return.
+ """
+
+ def foo_method(self, arg, _):
+ """docstring ...
+
+ Args:
+ arg (int): An argument.
+ """
+ pass
+
+
+class Foo:
+ """test_useless_docs_ignored_argument_names_google
+ Example of a method documenting the return type that an
+ implementation should return.
+ """
+
+ def foo_method(self, arg, _, _ignored): # [useless-type-doc, useless-param-doc]
+ """docstring ...
+
+ Args:
+ arg (int): An argument.
+ _ (float): Another argument.
+ _ignored: Ignored argument.
+ """
+ pass
diff --git a/tests/functional/ext/docparams/return/missing_return_doc_Google.txt b/tests/functional/ext/docparams/return/missing_return_doc_Google.txt
index 1c226ddcb..ea8e81200 100644
--- a/tests/functional/ext/docparams/return/missing_return_doc_Google.txt
+++ b/tests/functional/ext/docparams/return/missing_return_doc_Google.txt
@@ -1,3 +1,7 @@
-redundant-returns-doc:42:0:48:15:my_func:Redundant returns documentation:UNDEFINED
-redundant-returns-doc:51:0:57:15:my_func:Redundant returns documentation:UNDEFINED
-redundant-returns-doc:60:0:66:11:my_func:Redundant returns documentation:UNDEFINED
+redundant-returns-doc:43:0:49:15:my_func:Redundant returns documentation:UNDEFINED
+redundant-returns-doc:52:0:58:15:my_func:Redundant returns documentation:UNDEFINED
+redundant-returns-doc:61:0:67:11:my_func:Redundant returns documentation:UNDEFINED
+unreachable:95:8:95:17:Foo.foo_method:Unreachable code:UNDEFINED
+unreachable:112:8:112:17:Foo.foo_method:Unreachable code:UNDEFINED
+useless-param-doc:167:4:175:12:Foo.foo_method:"""_, _ignored"" useless ignored parameter documentation":UNDEFINED
+useless-type-doc:167:4:175:12:Foo.foo_method:"""_"" useless ignored parameter type documentation":UNDEFINED
diff --git a/tests/functional/ext/docparams/return/missing_return_doc_required_Google.py b/tests/functional/ext/docparams/return/missing_return_doc_required_Google.py
index 55cb2e6f3..37546b34f 100644
--- a/tests/functional/ext/docparams/return/missing_return_doc_required_Google.py
+++ b/tests/functional/ext/docparams/return/missing_return_doc_required_Google.py
@@ -1,7 +1,7 @@
"""Tests for missing-return-doc and missing-return-type-doc for Google style docstrings
with accept-no-returns-doc = no"""
# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
-# pylint: disable=unused-argument
+# pylint: disable=unused-argument, too-few-public-methods
def my_func(self): # [missing-return-type-doc]
@@ -38,3 +38,37 @@ def my_func(self): # [missing-return-doc]
list(:class:`mymodule.Class`):
"""
return [mymodule.Class()]
+
+
+class Foo:
+ """test_finds_missing_property_return_type_google
+ Example of a property having return documentation in
+ a Google style docstring
+ """
+
+ @property
+ def foo_method(self): # [missing-return-type-doc]
+ """docstring ...
+
+ Raises:
+ RuntimeError: Always
+ """
+ raise RuntimeError()
+ return 10 # [unreachable]
+
+
+class Foo:
+ """test_ignores_non_property_return_type_google
+ Example of a class function trying to use `type` as return
+ documentation in a Google style docstring
+ """
+
+ def foo_method(self): # [missing-return-doc, missing-return-type-doc]
+ """int: docstring ...
+
+ Raises:
+ RuntimeError: Always
+ """
+ print(self)
+ raise RuntimeError()
+ return 10 # [unreachable]
diff --git a/tests/functional/ext/docparams/return/missing_return_doc_required_Google.txt b/tests/functional/ext/docparams/return/missing_return_doc_required_Google.txt
index 16587df8b..aa6775f5f 100644
--- a/tests/functional/ext/docparams/return/missing_return_doc_required_Google.txt
+++ b/tests/functional/ext/docparams/return/missing_return_doc_required_Google.txt
@@ -3,3 +3,8 @@ missing-return-doc:16:0:22:16:my_func:Missing return documentation:UNDEFINED
missing-return-doc:25:0:31:16:my_func:Missing return documentation:UNDEFINED
missing-return-type-doc:25:0:31:16:my_func:Missing return type documentation:UNDEFINED
missing-return-doc:34:0:40:29:my_func:Missing return documentation:UNDEFINED
+missing-return-type-doc:50:4:57:17:Foo.foo_method:Missing return type documentation:UNDEFINED
+unreachable:57:8:57:17:Foo.foo_method:Unreachable code:UNDEFINED
+missing-return-doc:66:4:74:17:Foo.foo_method:Missing return documentation:UNDEFINED
+missing-return-type-doc:66:4:74:17:Foo.foo_method:Missing return type documentation:UNDEFINED
+unreachable:74:8:74:17:Foo.foo_method:Unreachable code:UNDEFINED