Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 4e467fe

Browse files
asottilesambhav
andauthored
Fix IndexError on strange backslash docstring (#506)
* Fix IndexError on strange backslash docstring * Formatting fixes Co-authored-by: Sambhav Kothari <[email protected]>
1 parent d5448f0 commit 4e467fe

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

docs/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Release Notes
77
Current Development Version
88
---------------------------
99

10+
Bug Fixes
11+
12+
* Fix ``IndexError`` crash on one-line backslashed docstrings (#506).
13+
1014

1115
5.1.0 - August 22nd, 2020
1216
---------------------------

src/pydocstyle/checker.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,11 @@ def check_indent(self, definition, docstring):
284284
indents = [leading_space(l) for l in lines if not is_blank(l)]
285285
if set(' \t') == set(''.join(indents) + indent):
286286
yield violations.D206()
287-
if (len(indents) > 1 and min(indents[:-1]) > indent or
288-
indents[-1] > indent):
287+
if (len(indents) > 1 and min(indents[:-1]) > indent) or (
288+
len(indents) > 0 and indents[-1] > indent
289+
):
289290
yield violations.D208()
290-
if min(indents) < indent:
291+
if len(indents) > 0 and min(indents) < indent:
291292
yield violations.D207()
292293

293294
@check_for(Definition)

src/tests/test_cases/functions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,8 @@ class inner():
7070
pass
7171

7272
pass
73+
74+
75+
def func_with_weird_backslash():
76+
"""Test a function with a weird backslash.\
77+
"""

0 commit comments

Comments
 (0)