Skip to content

Commit

Permalink
fix some docstring crashes (#1593)
Browse files Browse the repository at this point in the history
Allow removing some trailing whitespace
  • Loading branch information
JelleZijlstra authored Aug 13, 2020
1 parent 8842c5f commit 5e1f620
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/black/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6063,7 +6063,7 @@ def _stringify_ast(
and field == "value"
and isinstance(value, str)
):
normalized = re.sub(r" *\n[ \t]+", "\n ", value).strip()
normalized = re.sub(r" *\n[ \t]*", "\n", value).strip()
else:
normalized = value
yield f"{' ' * (depth+2)}{normalized!r}, # {value.__class__.__name__}"
Expand Down
18 changes: 17 additions & 1 deletion tests/data/docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def zort():

def poit():
"""
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.
Consectetur adipiscing elit:
- sed do eiusmod tempor incididunt ut labore
Expand All @@ -58,6 +58,14 @@ def poit():
pass


def under_indent():
"""
These lines are indented in a way that does not
make sense.
"""
pass


def over_indent():
"""
This has a shallow indent
Expand Down Expand Up @@ -136,6 +144,14 @@ def poit():
pass


def under_indent():
"""
These lines are indented in a way that does not
make sense.
"""
pass


def over_indent():
"""
This has a shallow indent
Expand Down

0 comments on commit 5e1f620

Please sign in to comment.