forked from pylint-dev/pylint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
missing_return_doc_Sphinx.py
109 lines (76 loc) · 2.12 KB
/
missing_return_doc_Sphinx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"""Tests for missing-return-doc and missing-return-type-doc for Sphinx style docstrings"""
# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
# pylint: disable=unused-argument, disallowed-name, too-few-public-methods, missing-class-docstring
# pylint: disable=unnecessary-pass
import abc
def my_func(self):
"""find_sphinx_returns
:return: Always False
:rtype: bool
"""
return False
def my_func(self, doc_type):
"""ignores_sphinx_return_none
:param doc_type: Sphinx
:type doc_type: str
"""
return
def my_func(self):
"""finds_sphinx_return_custom_class
:returns: An object
:rtype: :class:`mymodule.Class`
"""
return mymodule.Class()
def my_func(self):
"""finds_sphinx_return_list_of_custom_class
:returns: An object
:rtype: list(:class:`mymodule.Class`)
"""
return [mymodule.Class()]
def my_func(self): # [redundant-returns-doc]
"""warns_sphinx_redundant_return_doc
:returns: One
"""
return None
def my_func(self): # [redundant-returns-doc]
"""warns_sphinx_redundant_rtype_doc
:rtype: int
"""
return None
def my_func(self):
"""ignores_sphinx_redundant_return_doc_multiple_returns
:returns: One
:rtype: int
:returns: None sometimes
:rtype: None
"""
if a_func():
return None
return 1
def my_func_with_yield(self):
"""ignore_sphinx_redundant_return_doc_yield
:returns: One
:rtype: generator
"""
for value in range(3):
yield value
class Foo:
"""test_ignores_return_in_abstract_method_sphinx
Example of an abstract method documenting the return type that an
implementation should return.
"""
@abc.abstractmethod
def foo(self):
"""docstring ...
:returns: Ten
:rtype: int
"""
return 10
class Foo:
def test_ignores_ignored_argument_names_sphinx(self, arg, _):
"""Example of a method documenting the return type that an
implementation should return.
:param arg: An argument.
:type arg: int
"""
pass