mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Byte strings aren't docstrings (#8350)
We previously incorrectly treated byte strings in docstring position as docstrings because black does so (https://github.com/astral-sh/ruff/pull/8283#discussion_r1375682931, https://github.com/psf/black/issues/4002), even CPython doesn't recognize them: ```console $ python3.12 Python 3.12.0 (main, Oct 6 2023, 17:57:44) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> def f(): ... b""" a""" ... >>> print(str(f.__doc__)) None ``` <!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? -->
This commit is contained in:
parent
98b3d716c6
commit
f483ed4240
3 changed files with 28 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue