Skip to content

Commit 37914ac

Browse files
authored
Merge pull request #14 from pixelneo/no-body
Function with no body fix
2 parents e1b9599 + 84b2b29 commit 37914ac

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

python/pydocstring.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,16 @@ def _object_tree(self):
129129
sig_line = last_row
130130

131131
# remove obj_indent from the beginning of all lines
132-
data = '\n'.join([re.sub('^'+obj_indent, '', l) for l in lines])
132+
lines = [re.sub('^'+obj_indent, '', l) for l in lines]
133+
for i, l in enumerate(reversed(lines)):
134+
if l.strip() == '':
135+
lines.pop()
136+
else:
137+
break
138+
if len(lines) == 1:
139+
lines.append(f'{self.env.python_indent}pass')
140+
141+
data = '\n'.join(lines)
133142
try:
134143
tree = ast.parse(data)
135144
except Exception as e:

0 commit comments

Comments
 (0)