Description
Issue
# >>> Call Args: ['tests/data/format/numpydoc/numpydoc_parameter_spacing.py', '--style', 'numpydoc', '--style', 'pep257']
This call fails with an index error because section[0]
has length 0, therefore section[0][0]
returns an index error.
Fix
Modifying:
pydocstringformatter/pydocstringformatter/_formatting/base.py
Lines 275 to 282 in c749fc6
To:
# Check that indent on first line of section didn't get weird
first_section = True
for section in new_sections.values():
if first_section:
section[0] = section[0].lstrip()
first_section = False
elif len(section[0]) > 0 and not section[0][0].isspace(): # <<<<<< this is the fix
section[0] = f"{' ' * indent_length:s}{section[0]:s}"
Related:
Breaking call:
# >>> Call Args: ['tests/data/format/summary_splitter/regression_151.py', '--style', 'numpydoc', '--linewrap-full-docstring']
Fix:
summary_lines = summary.splitlines()
# Here is the fix, checks if the summary line is empty before going though
if len(summary_lines) == 0:
summary_lines = [""]
new_summary = "\n".join(
textwrap.wrap(
summary_lines[0],
width=line_length,
initial_indent=" " * (indent_length + quotes_length),
subsequent_indent=" " * indent_length,
replace_whitespace=True,
)
)[indent_length + quotes_length :]