Skip to content

Commit fea4116

Browse files
committed
fix: handle case where class contains only docstring
1 parent 112a80b commit fea4116

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/docformatter/format.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@ def _get_class_docstring_newlines(
265265
if tokens[j].string.startswith("#"):
266266
return 0
267267

268+
while j < len(tokens):
269+
if tokens[j].type in (tokenize.NL, tokenize.NEWLINE):
270+
j += 1
271+
continue
272+
273+
if tokens[j].type == tokenize.DEDENT:
274+
return 2
275+
276+
break
277+
268278
return 1
269279

270280

0 commit comments

Comments
 (0)