Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Byte strings aren't docstrings #8350

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion crates/ruff_python_formatter/src/statement/suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
24 changes: 24 additions & 0 deletions crates/ruff_python_formatter/tests/snapshots/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading