File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed
src/pytkdocs/parsers/docstrings
tests/test_parsers/test_docstrings Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -89,11 +89,11 @@ def read_parameters_section(
8989 if signature_param .default is not empty :
9090 default = signature_param .default
9191 kind = signature_param .kind
92-
92+
9393 description = param .description or ""
9494 if not description :
9595 self .error (f"No description for parameter '{ name } '" )
96-
96+
9797 parameters .append (
9898 Parameter (
9999 name = param .arg_name ,
@@ -190,29 +190,29 @@ def read_return_section(
190190 A `Section` object (or `None` if section is empty).
191191 """
192192 if docstring_obj .returns :
193- return_obj = docstring_obj .returns
194-
193+ return_obj = docstring_obj .returns
194+
195195 if return_obj .description :
196196 description = return_obj .description
197- else :
197+ else :
198198 self .error ("Empty return description" )
199199 description = ""
200200
201201 if self .context ["signature" ]:
202202 annotation = self .context ["signature" ].return_annotation
203203 else :
204204 annotation = self .context ["annotation" ]
205-
205+
206206 if annotation is empty and return_obj .type_name :
207207 annotation = return_obj .type_name
208-
208+
209209 if not annotation :
210210 self .error ("No return type annotation" )
211211 annotation = ""
212212
213213 if annotation or description :
214214 return Section (Section .Type .RETURN , AnnotatedObject (annotation , description ))
215-
215+
216216 return None
217217
218218 def read_examples_section (
Original file line number Diff line number Diff line change @@ -103,27 +103,28 @@ def test_sections_without_description():
103103 bool
104104 """
105105 )
106-
106+
107107 # Assert that errors are as expected
108108 assert len (sections ) == 4
109109 assert len (errors ) == 6
110110 for error in errors [:4 ]:
111111 assert "param" in error
112112 assert "exception" in errors [4 ]
113113 assert "return description" in errors [5 ]
114-
114+
115115 # Assert that no descriptions are ever None (can cause exceptions downstream)
116116 assert sections [1 ].type is Section .Type .PARAMETERS
117117 for p in sections [1 ].value :
118118 assert p .description is not None
119-
119+
120120 assert sections [2 ].type is Section .Type .EXCEPTIONS
121121 for p in sections [2 ].value :
122122 assert p .description is not None
123-
123+
124124 assert sections [3 ].type is Section .Type .RETURN
125125 assert sections [3 ].value .description is not None
126126
127+
127128def test_property_docstring ():
128129 """Parse a property docstring."""
129130 class_ = Loader ().get_object_documentation ("tests.fixtures.parsing.docstrings.NotDefinedYet" )
You can’t perform that action at this time.
0 commit comments