Skip to content

Preserve blank line before raw docstrings #3944

@konstin

Description

@konstin

Describe the style change

Currently, black preserves the blank line before regular doc strings, but not before raw docstrings. It should preserve them before both.

Input

class TextIOWrapper(TextIOBase):
    
    r"""Character and line based layer over a BufferedIOBase object, buffer.

    [...]
    """

    _CHUNK_SIZE = 2048
    
class TextIOWrapper(TextIOBase):
    
    """Character and line based layer over a BufferedIOBase object, buffer.

    [...]
    """

    _CHUNK_SIZE = 2048

Examples in the current Black style

class TextIOWrapper(TextIOBase):
    r"""Character and line based layer over a BufferedIOBase object, buffer.

    [...]
    """

    _CHUNK_SIZE = 2048


class TextIOWrapper(TextIOBase):

    """Character and line based layer over a BufferedIOBase object, buffer.

    [...]
    """

    _CHUNK_SIZE = 2048

Desired style

class TextIOWrapper(TextIOBase):

    r"""Character and line based layer over a BufferedIOBase object, buffer.

    [...]
    """

    _CHUNK_SIZE = 2048


class TextIOWrapper(TextIOBase):

    """Character and line based layer over a BufferedIOBase object, buffer.

    [...]
    """

    _CHUNK_SIZE = 2048

Additional context

Currently, black doesn't seem to consider raw triple quotes strings as docstrings, even though cpython (and PEP 257) do. I've seen some raw triple quoted doc string uses in the wild, such as the above example from cpython.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions