diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py index 60c655f686e97..17edab372513d 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py @@ -93,6 +93,10 @@ def docstring_that_ends_with_quote_and_a_line_break3(): """ +class ByteDocstring: + b""" has leading whitespace""" + first_statement = 1 + class TabbedIndent: def tabbed_indent(self): """check for correct tabbed formatting diff --git a/crates/ruff_python_formatter/src/statement/suite.rs b/crates/ruff_python_formatter/src/statement/suite.rs index fa50c8ba42df9..a32184f5b7da3 100644 --- a/crates/ruff_python_formatter/src/statement/suite.rs +++ b/crates/ruff_python_formatter/src/statement/suite.rs @@ -554,7 +554,6 @@ impl<'a> DocstringStmt<'a> { match value.as_ref() { Expr::StringLiteral(value) if !value.implicit_concatenated => Some(DocstringStmt(stmt)), - Expr::BytesLiteral(value) if !value.implicit_concatenated => Some(DocstringStmt(stmt)), _ => None, } } diff --git a/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap index 3b2867715f843..580b55562af07 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap @@ -99,6 +99,10 @@ def docstring_that_ends_with_quote_and_a_line_break3(): """ +class ByteDocstring: + b""" has leading whitespace""" + first_statement = 1 + class TabbedIndent: def tabbed_indent(self): """check for correct tabbed formatting @@ -213,6 +217,11 @@ def docstring_that_ends_with_quote_and_a_line_break3(): """he said "the news of my death have been greatly exaggerated" """ +class ByteDocstring: + b""" has leading whitespace""" + first_statement = 1 + + class TabbedIndent: def tabbed_indent(self): """check for correct tabbed formatting @@ -327,6 +336,11 @@ def docstring_that_ends_with_quote_and_a_line_break3(): """he said "the news of my death have been greatly exaggerated" """ +class ByteDocstring: + b""" has leading whitespace""" + first_statement = 1 + + class TabbedIndent: def tabbed_indent(self): """check for correct tabbed formatting @@ -441,6 +455,11 @@ def docstring_that_ends_with_quote_and_a_line_break3(): """he said "the news of my death have been greatly exaggerated" """ +class ByteDocstring: + b""" has leading whitespace""" + first_statement = 1 + + class TabbedIndent: def tabbed_indent(self): """check for correct tabbed formatting @@ -555,6 +574,11 @@ def docstring_that_ends_with_quote_and_a_line_break3(): """he said "the news of my death have been greatly exaggerated" """ +class ByteDocstring: + b""" has leading whitespace""" + first_statement = 1 + + class TabbedIndent: def tabbed_indent(self): """check for correct tabbed formatting