Skip to content

Commit

Permalink
Found another behavior change
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Dec 10, 2023
1 parent 7ee8e6f commit 8e92680
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/black/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def _is_triple_quoted_string(self) -> bool:
@property
def is_docstring(self) -> bool:
"""Is the line a docstring?"""
if Preview.format_module_docstring not in self.mode:
if Preview.unify_docstring_detection not in self.mode:
return self._is_triple_quoted_string
return bool(self) and is_docstring(self.leaves[0], self.mode)

Expand Down
2 changes: 1 addition & 1 deletion src/black/mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class Preview(Enum):
single_line_format_skip_with_multiple_comments = auto()
long_case_block_line_splitting = auto()
allow_form_feeds = auto()
format_module_docstring = auto()
unify_docstring_detection = auto()


class Deprecated(UserWarning):
Expand Down
2 changes: 1 addition & 1 deletion src/black/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def is_docstring(leaf: Leaf, mode: Mode) -> bool:
return False

if (
Preview.format_module_docstring in mode
Preview.unify_docstring_detection in mode
and leaf.parent
and leaf.parent.type == syms.simple_stmt
and not leaf.parent.prev_sibling
Expand Down
7 changes: 7 additions & 0 deletions tests/data/cases/preview_no_blank_line_before_docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class MultilineDocstringsAsWell:
and on so many lines...
"""

class SingleQuotedDocstring:

"I'm a docstring but I don't even get triple quotes."

# output

Expand Down Expand Up @@ -57,3 +60,7 @@ class MultilineDocstringsAsWell:
and on so many lines...
"""


class SingleQuotedDocstring:
"I'm a docstring but I don't even get triple quotes."

0 comments on commit 8e92680

Please sign in to comment.