Skip to content

Commit

Permalink
Merge pull request #8 from warsaw/issue3
Browse files Browse the repository at this point in the history
Docstrings can be a single line #8

Module docstrings always start in column zero.  If they don't I don't care 馃槃 .  That doesn't necessarily mean this heuristic won't false positive for other non-module docstrings in column 0, but for now, let's call it good enough.  Until it's not.
  • Loading branch information
warsaw committed Jan 13, 2021
2 parents 1989868 + 7e56931 commit 01d25ae
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions blue/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
def is_docstring(leaf: Leaf) -> bool:
# Most of this function was copied from Black!

if not is_multiline_string(leaf):
# For the purposes of docstring re-indentation, we don't need to do anything
# with single-line docstrings.
return False

if prev_siblings_are(
leaf.parent, [None, token.NEWLINE, token.INDENT, syms.simple_stmt]
):
Expand All @@ -41,7 +36,7 @@ def is_docstring(leaf: Leaf) -> bool:
# grammar. We're safe to return True without further checks.
return True

if leaf.parent.prev_sibling is None:
if leaf.parent.prev_sibling is None and leaf.column == 0:
# Identify module docstrings.
return True

Expand Down

0 comments on commit 01d25ae

Please sign in to comment.