Skip to content

Commit af502f1

Browse files
committed
Fix crash with almost empty docstrings
1 parent f5a663b commit af502f1

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

pydocstringformatter/_formatting/formatters_default.py

+3
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ def treat_summary(
152152
description_exists: bool,
153153
) -> str:
154154
"""Add a period to the end of single-line docstrings and summaries."""
155+
if not summary:
156+
return summary
157+
155158
if summary[-1] in self.END_OF_SENTENCE_PUNCTUATION:
156159
return summary
157160

pydocstringformatter/_formatting/formatters_pep257.py

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def treat_summary(
3838
"""Split a summary and body if there is a period after the summary."""
3939
new_summary = None
4040

41+
if not summary:
42+
return summary
43+
4144
if _utils.is_rst_title(summary):
4245
return summary
4346

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class GithubIssue151:
2+
""" """
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class GithubIssue151:
2+
""""""

0 commit comments

Comments
 (0)