Skip to content

Commit d6709d9

Browse files
committed
FIX parsing of type-only return params
1 parent 972b2dc commit d6709d9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

numpydoc/docscrape.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,18 @@ def _read_sections(self):
211211
else:
212212
yield name, self._strip(data[2:])
213213

214-
def _parse_param_list(self, content):
214+
def _parse_param_list(self, content, single_element_is_type=False):
215215
r = Reader(content)
216216
params = []
217217
while not r.eof():
218218
header = r.read().strip()
219219
if ' : ' in header:
220220
arg_name, arg_type = header.split(' : ')[:2]
221221
else:
222-
arg_name, arg_type = header, ''
222+
if single_element_is_type:
223+
arg_name, arg_type = '', header
224+
else:
225+
arg_name, arg_type = header, ''
223226

224227
desc = r.read_to_next_unindented_line()
225228
desc = dedent_lines(desc)
@@ -351,10 +354,12 @@ def _parse(self):
351354
self._error_location("The section %s appears twice"
352355
% section)
353356

354-
if section in ('Parameters', 'Returns', 'Yields', 'Raises',
355-
'Warns', 'Other Parameters', 'Attributes',
357+
if section in ('Parameters', 'Other Parameters', 'Attributes',
356358
'Methods'):
357359
self[section] = self._parse_param_list(content)
360+
elif section in ('Returns', 'Yields', 'Raises', 'Warns'):
361+
self[section] = self._parse_param_list(
362+
content, single_element_is_type=True)
358363
elif section.startswith('.. index::'):
359364
self['index'] = self._parse_index(section, content)
360365
elif section == 'See Also':

0 commit comments

Comments
 (0)