Skip to content

Commit edf4976

Browse files
authored
Merge branch 'main' into bugfix/empty_section
2 parents c245c03 + 9268fd6 commit edf4976

File tree

9 files changed

+42
-4
lines changed

9 files changed

+42
-4
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
rev: v4.3.0
44
hooks:
55
- id: trailing-whitespace
6-
exclude: "tests/data/format/whitespace_stripper|tests/data/format/quotes_type|tests/data/format/newlines|tests/test_config.py"
6+
exclude: "tests/data/format/no_whitespace_stripper|tests/data/format/whitespace_stripper|tests/data/format/quotes_type|tests/data/format/newlines|tests/test_config.py"
77
- id: end-of-file-fixer
88
exclude: "tests/data/format/newlines"
99
- id: check-yaml
@@ -42,7 +42,7 @@ repos:
4242
exclude: *test-data
4343
additional_dependencies: [flake8-typing-imports==1.10.1]
4444
- repo: https://github.com/pycqa/pylint
45-
rev: v2.15.0
45+
rev: v2.15.2
4646
hooks:
4747
- id: pylint
4848
exclude: *test-data

pydocstringformatter/_formatting/_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
def is_rst_title(summary: str) -> bool:
66
"""Check if the second line of a summary is one recurring character."""
77
# If second line is one recurring character we're dealing with a rst title
8-
last_line = summary.splitlines()[-1].lstrip()
8+
if not (last_line := summary.splitlines()[-1].lstrip()):
9+
return False
910
return last_line.count(last_line[0]) == len(last_line)

pydocstringformatter/_formatting/formatters_default.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def treat_summary(
8888
# ending quotes
8989
line_length -= quotes_length + 1
9090

91-
summary_lines = summary.splitlines()
91+
if not (summary_lines := summary.splitlines()):
92+
summary_lines = [""]
9293

9394
new_summary = "\n".join(
9495
textwrap.wrap(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--no-strip-whitespaces
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
""" A multi-line
2+
docstring
3+
"""
4+
5+
""" A multi-line
6+
docstring
7+
"""
8+
9+
""" My docstring.
10+
11+
My indented section
12+
"""
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
""" A multi-line .
2+
3+
docstring
4+
"""
5+
6+
""" A multi-line .
7+
8+
docstring
9+
10+
"""
11+
12+
""" My docstring.
13+
14+
15+
16+
My indented section
17+
18+
"""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--linewrap-full-docstring
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class GithubIssue151:
2+
""" """
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class GithubIssue151:
2+
""""""

0 commit comments

Comments
 (0)