@@ -242,40 +242,39 @@ def _parse_returns_section_patched(self, section: str) -> list[str]:
242242 multi = len (fields ) > 1
243243 use_rtype = False if multi else self ._config .napoleon_use_rtype
244244 lines : list [str ] = []
245+ header : list [str ] = []
245246 is_logged_header = False
246247
247248 for _name , _type , _desc in fields :
248- is_header_block = False
249+ # self._consume_returns_section() stores the header block
250+ # into `_type` argument, while `_name` has to be empty string and
251+ # `_desc` has to be empty list of strings
249252 if _name == "" and (not _desc or len (_desc ) == 1 and _desc [0 ] == "" ):
250- # self._consume_returns_section() stores the header block
251- # into `_type` argument, while `_name` and `_desc` have to be empty
252- is_header_block = True
253253 if not is_logged_header :
254254 docstring .logger .info (
255255 "parse a header block of 'Returns' section" ,
256256 location = self ._get_location (),
257257 )
258258 is_logged_header = True
259259
260+ # build a list with lines of the header block
261+ header .extend ([_type ])
262+ continue
263+
260264 if use_rtype :
261265 field = self ._format_field (_name , "" , _desc )
262- elif not is_header_block :
263- field = self ._format_field (_name , _type , _desc )
264266 else :
265- # assign processing field to `_type` value
266- field = _type
267+ field = self ._format_field (_name , _type , _desc )
267268
268269 if multi :
269270 if lines :
270- if is_header_block :
271- # add the next line of header text
272- lines .append (field )
273- else :
274- lines .extend (self ._format_block (" * " , field ))
271+ lines .extend (self ._format_block (" * " , field ))
275272 else :
276- if is_header_block :
277- # add a beginning of header text
278- lines .extend ([":returns:" , "" , field ])
273+ if header :
274+ # add the header block + the 1st parameter stored in `field`
275+ lines .extend ([":returns:" , "" ])
276+ lines .extend (self ._format_block (" " * 4 , header ))
277+ lines .extend (self ._format_block (" * " , field ))
279278 else :
280279 lines .extend (self ._format_block (":returns: * " , field ))
281280 else :
0 commit comments