Skip to content

Commit c8abbbf

Browse files
jspaezpDanielNoord
authored andcommitted
handled empty section name whitespaces
1 parent 8835205 commit c8abbbf

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pydocstringformatter/_formatting/formatters_numpydoc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ def treat_sections(
121121
# summary. They have neither a section header nor the
122122
# line of hyphens after it.
123123
indent_length = section_lines[1].index("-")
124-
section_lines[1] = " " * indent_length + "-" * len(section_name)
124+
125+
if section_name:
126+
section_lines[1] = " " * indent_length + "-" * len(section_name)
127+
125128
if first_section:
126129
# If the second line were not hyphens, the section name
127130
# would be summary. This assumes triple quotes, but that

tests/data/format/multi_style/numpydoc_parameter_spacing.py.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def sincos(theta):
4343
If `theta` is not a float.
4444

4545

46-
46+
----
4747
sin: float
4848
the sine of theta
4949
cos: float

0 commit comments

Comments
 (0)